Redirect rule on bucket cause too many redirects (redirect Loop)
See original GitHub issueIntro
My Gatsby app is deployed on S3 and everytime I deploy with this plugin, it writes some redirect rules that loops. My app has hybrid routing (static and dynamic). In my project the src/pages has this structure: src/pages |-- index.js |-- 404.js |-- app |-- _login.js |-- _logout.js |-- index.js
I basically follow gatsby client route documentation and also use gatsby-plugin-create-client-paths. The bucket has Hosting Static Site ON and it’s public readable. _login.js and _logout.js (with the underscore as first character) so that Gatsby doesn’t generate their related pages (see here for detail)
Problem
When I deploy the plugin (I assume) writes redirect rules on the bucket, this cause a TOO_MANY_REDIRECT error cause it loops.
this are the rules on my bucket:
<RoutingRules> <RoutingRule> <Condition> <KeyPrefixEquals>app/</KeyPrefixEquals> </Condition> <Redirect> <ReplaceKeyWith>app</ReplaceKeyWith> <HttpRedirectCode>302</HttpRedirectCode> </Redirect> </RoutingRule> </RoutingRules>
And if i try to access <S3-URL>/app/login it returns TOO_MANY_BLABLA.
running:
curl -i <S3-URL>/app/login
I get 302 and location=<S3-URL>/app
by following the location:
curl -i <S3-URL>/app
I get 302 and location=/app/ and then it starts looping.
Solution
When I remove the redirect rules on my bucket everything work fine. I can access /app/login directly from URL without any problems and in the bucket I don’t have those file deployed under app/login/index.html or app/logout/index.html. (If those file exist it means that they are created at compile time and therefore they are static routes)
Question
Can I disabled the plugin from write redirect rules and just deploy?
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
I’ll provide a reprex as soon as possible. Thanks for your help.
Your enthusiasm is contagious. I’ve had another brief look into this. We generate the redirect rules here. This is the only place we generate them. Since we just generate rules for whatever Gatsby gives us, looks like this isn’t a bug in our plugin.
I think ultimately #77 is the root cause. I’m going to close this issue, but feel free to re-open it if you have reason to believe this is a separate bug. A reprex would still be useful, but mainly for the purpose of testing #77.