Client-only routes cause 302 redirects or 404 responses
See original GitHub issueI’m building an app on top of Gatsby using this package to bundle and deploy the front-end.
Reproduction:
- Clone this starter by Nader Dabit that contains some client-side routing https://github.com/dabit3/gatsby-auth-starter-aws-amplify
- Deploy it with gatsby-plugin-s3
Current behavior:
RoutingRules
will be generated on the s3 bucket which will cause 302 redirects on /app/login
to /app
. Same thing if you try to hit /app/login
directly.
Potential fix:
Add a flag to not generate RoutingRules
via the CLI?
Manual fix:
After every deployment, remove certain routes on the s3 buckets RoutingRules
Closing Remarks:
Thank you so much for your hard work. I love/recommend this package a lot.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:10 (2 by maintainers)
Top Results From Across the Web
How To Fix the HTTP 302 Error (5 Methods) - Kinsta
HTTP 302 codes are useful to temporarily redirect website users to another URL. If you're getting this error code, here are 5 ways...
Read more >GatsbyJs client only paths goes to 404 page when the url is ...
The general solution is to tell your server to redirect the /sample/ path to your /sample/index.html file. The way to do this depends...
Read more >Redirects (301/302) versus errors (404) | SEO Forum - Moz
I am not able to convincingly decide between using redirects versus using 404 errors. People are giving varied opinions. Here are my cases...
Read more >List of HTTP status codes - Ryte Wiki
4 Status code 3xx - redirection. 4.1 Status code 301; 4.2 Status code 302. 5 Status code 400|Status code 4xx – client error....
Read more >302 vs 301 Redirects: What You Need to Know - BrightEdge
Did you know 404 redirects are bad? What about 302 and 301 redirects? Discover what each redirect means and how to do them...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi everyone, I create an example project to reproduce #133 . I’ve tested it and it loops because of the rules written on the bucket.
Even if it’s not a bug in your plugin, I’ll leave the project here so that anyone intrested can investigate.
If I’ll find out anything I’m gonna write the info on this issue.
Thank @JoshuaWalsh for your help, have a nice day everyone.
Hey @jariz, I’m thinking about this one. In an ideal world we would preserve the path. In httpd you would do this using a rewrite, so instead of returning a 301/302 it would perform the redirect within the web server and just return the contents of the destination page.
S3 doesn’t support this and I was wondering how we could. Initially it seemed to me it would need a Lambda@Edge Origin Request function for this, but I’ve thought of a simpler way:
What if we just copy the contents of the rewrite destination to the original path? That should function the same as a traditional rewrite. Obviously the new behaviour should be optional, but I think it would help for many clientside-only route use cases.