1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Next.js静的サイトをS3 + CloudFrontで公開したら403になったので調査した

1
Posted at

Next.jsをS3 + CloudFrontへデプロイしたところ、

/posts/hello

だけ403になりました。

確認したことは以下です。

CloudFrontキャッシュ
S3 Bucket Policy
OAC設定
S3上のファイル存在確認

どれも問題なし。

原因はCloudFrontが

/posts/hello

/posts/hello/index.html

へ変換していなかったことでした。

さらに、CloudFront Function用のJavaScriptファイルは作成済みだったものの、Terraformで aws_cloudfront_function を定義しておらず、AWS上にはFunction自体が存在していませんでした。

CloudFront FunctionをTerraform管理に追加し、Distributionへ関連付けることで解決しました。

記事では原因の切り分け手順とTerraformのコード例をまとめています。

同じように「403だけどS3にもファイルがある」という状態の方の参考になれば幸いです。

本記事はこちら
https://d3o7t81m8nyt3g.cloudfront.net/blog/2026-06-26-cloudfront-403-url-rewrite

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?