-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Page resources not found for 404 page, doesn't render react. #31455
Comments
Error 403 suggests that your S3 / CloudFront is incorrectly configured. Gatsby checks for "normal" status codes: 404, 200, 500. But when it sees unexpected status code 403 it simply retries 3 times and then surrenders: gatsby/packages/gatsby/cache-dir/loader.js Lines 137 to 186 in d38f4d9
You need to configure your S3 properly to make sure CloudFront returns a 404 status code and not 403. Check out those articles on more details and how to fix the configuration: https://aws.amazon.com/premiumsupport/knowledge-center/s3-website-cloudfront-error-403/ So this error is not really an error with Gatsby but rather with your AWS setup. As stated, this is slightly tangential to Gatsby, and it seems like we’ve provided enough information to make an informed decision. If this is not the case, or if we can help further--please don’t hesitate to reach out or comment on this issue, and we’d love to take another look. Thanks for using Gatsby 💪 |
Thanks for the great solution! My apologies for not recognizing the true scope of the issue. For anyone who finds this in the future, I simply updated my s3 Access Control List to allow Everyone (public access) to list and read all objects. Originally, we were setting each object's permissions as public in the deploy script, but the overall bucket itself didn't allow all objects to be accessible, so the non-existent object was throwing a 403 instead of the 404. |
This issue seems to have surfaced again.
We are running on Gatsby 4.24.8 Any suggestions? |
Description
On deployed site, when an non-existent route is hit, the resulting 404 page is unable to load page-data.json and thus doesn't not render React throwing the error
Error: page resources for /fake-page not found. Not rendering React.
The proper static page is displayed, however, react functionality is disabled. I searched other issues, but was unable to find a solution that worked.For whatever reason, if you attempt to hit
/fake-path
, it attempts to load the page data for that non-existent path and not the 404 path. (looks for../page-data/fake-path/page-data.json
, instead of../page-data/404/page-data.json
). This only happens when the site is deployed using S3 and Cloudfront, however, things work as expected when running locally usinggatsby serve
.#19618 was closed without a clear resolution due to the myriad of suggestions and related comments exceeded the original issue scope.
I have created a minimal reproduction that successfully recreates the problem. Any help with this is much appreciated.
We are using gatsby-plugin-s3 to optimize caching as well.
Steps to reproduce
This live reproduction renders the proper 404 page, but you'll see the error in the console.
Github Repo
Expected result
Redirect to 404, page-data.json for 404 page successfully loaded, no uncaught errors and React succesfully rendered.
Actual result
Error: page resources for /fake-page not found. Not rendering React.
page-data.json return 403 codes
Environment
The text was updated successfully, but these errors were encountered: