question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Redirect rule on bucket cause too many redirects (redirect Loop)

See original GitHub issue

Intro

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:closed
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
pierluigi-giancolacommented, Mar 16, 2020

I’ll provide a reprex as soon as possible. Thanks for your help.

0reactions
JoshuaWalshcommented, Mar 16, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix The ERR_TOO_MANY_REDIRECTS Error - Kinsta
The ERR_TOO_MANY_REDIRECTS is, as the error suggests, caused by too many redirects, resulting in a redirect loop.
Read more >
Too Many Redirects: What This Error Means & How to Fix It
The too many redirects error indicates that your browser is stuck in an infinite redirection loop. That means your browser is trying to ......
Read more >
AWS Cloudfront redirected you too many times - Stack Overflow
I have a problem with redirects in cloudfront. I configure Cloudflare two NS in my webpanel first. I follow this steps after this:....
Read more >
Too Many Redirects: What This Error Means And How to Fix It
The three most common reasons behind seeing “Too many redirects” on your website are: A valid SSL/TLS certificate is missing. A redirect loop ......
Read more >
How to Fix “Too Many Redirects” WordPress Error - DreamHost
The “too many redirects” error happens when your WordPress website gets stuck in redirection loops. For example, it may try to send you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found