sst: Bug: Static Site 403's for route based index pages (Cloudfront + s3 issue)

I’m fully stumped on this issue.

I followed the suggested implementation for a gatsby site here. My gatsby site builds a few pages

index.html
404.html
blog/
  - index.html

// lots of JS files that re-hydrate the app and handle regular JS "stuff"

If you navigate to / then use a <Link /> tag (from gatsby) everything works correctly. Because the app is hydrated. However, if you /blog you get a 403. A gatsby site will reload though, becuase of the hydration. As an example, on my site you can see that on refresh we get a 403 for this file:

image

however, I can see it in s3 here: image

Gatsby has a plugin for this https://gatsby-plugin-s3.jari.io/recipes/with-cloudfront/ that solves this issue. According to that plugin, in order to make an s3 bucket work, you need it to be public. That means you need to

In order for all the features of your site to work correctly, you must instead use your S3 bucket's Static Website Hosting Endpoint as the CloudFront origin

I looked at the aws docs and I see https://docs.aws.amazon.com/AmazonS3/latest/userguide/EnableWebsiteHosting.html which seems to say that you need to select Use This Bucket to enable static hosting. I don’t see how to do that in SST or CDK.

image


perhaps the better solution I should try is https://docs.aws.amazon.com/cdk/api/v2/docs/aws-amplify-alpha-readme.html which side steps the issue I guess? I dunno. I’ve been messing with this for 2 weeks now. 😭 and am fully out of ideas.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 15 (9 by maintainers)

Most upvoted comments

@minizwergi there is a bug fix in 2.5.1 version. Take a look at this issue