Skip to content
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

Redirects broken #3787

Closed
5 tasks done
raffclar opened this issue Nov 6, 2023 · 3 comments
Closed
5 tasks done

Redirects broken #3787

raffclar opened this issue Nov 6, 2023 · 3 comments
Labels
archived This issue has been locked. closed-for-staleness pending-triage response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@raffclar
Copy link

raffclar commented Nov 6, 2023

Before opening, please confirm:

  • I have checked to see if my question is addressed in the FAQ.
  • I have searched for duplicate or closed issues.
  • I have read the guide for submitting bug reports.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.

App Id

dfgwx0v13a7s4

AWS Region

eu-west-2

Amplify Hosting feature

Redirects

Frontend framework

React

Next.js version

N/A

Next.js router

App Router

Describe the bug

On Thursday 2nd November roughly around 6PM UTC we suddenly experienced a redirect loop with our website.

We investigated and discovered the cause of the redirect looping: our redirect rules that we haven't changed in almost a year. When we removed the rules, the looping stopped. We would like to restore the rules.

In the logs we saw this:

  1. User goes to https://subdomain.devdomain.co.uk
  2. User is redirected to https://subdomain.domain.co.uk
  3. User is redirected from https://subdomain.domain.co.uk to https://subdomain.domain.co.uk again.
  4. Redirects repeat until the browser stops the loop.

We've changed the domains and subdomains but here's what our rules used to look like:

[
    {
        "source": "https://subdomain.devdomain.co.uk/<*>”,
        "target": "https://subdomain.domain.co.uk/<*>",
        "status": "302",
        "condition": null
    },
    {
        "source": "https://subdomain.devdomain.co.uk",
        "target": "https://subdomain.domain.co.uk",
        "status": "302",
        "condition": null
    },
    {
        "source": "</^[^.]+$|\\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf)$)([^.]+$)/>",
        "target": "/index.html",
        "status": "200",
        "condition": null
    }
]

We now only have the third rule with the status 200. If we restore all three rules, the redirect loop returns.

Expected behavior

When navigating to https://subdomain.devdomain.co.uk we expect it to go to https://subdomain.domain.co.uk
When navigating to https://subdomain.devdomain.co.uk/abc we expect it to go to https://subdomain.domain.co.uk/abc

There should be no looping.

Reproduction steps

  1. Add these redirect rules to your app. Change the domains to ensure they work.
         "source": "https://subdomain.devdomain.co.uk/<*>”,
         "target": "https://subdomain.domain.co.uk/<*>",
         "status": "302",
         "condition": null
     },
     {
         "source": "https://subdomain.devdomain.co.uk",
         "target": "https://subdomain.domain.co.uk",
         "status": "302",
         "condition": null
     },
    
  2. Go to "source", (in the above that's https://subdomain.devdomain.co.uk)
  3. Experience redirect looping!

Build Settings

No response

Log output

# Put your logs below this line


Additional information

No response

@ferdingler
Copy link
Contributor

ferdingler commented Nov 7, 2023

Hi @raffclar , thanks for bringing this to our attention. We will look into what happened to your rewrite rules on Nov 2nd. But in the meantime, try keeping just the 1 rule without the /<*> placeholder. Basically keep these rules:

[
    {
        "source": "https://subdomain.devdomain.co.uk",
        "target": "https://subdomain.domain.co.uk",
        "status": "302",
        "condition": null
    },
    {
        "source": "</^[^.]+$|\\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf)$)([^.]+$)/>",
        "target": "/index.html",
        "status": "200",
        "condition": null
    }
]

You shouldn't get a redirect loop with these and you should still get the same redirect behavior on nested paths.

@ferdingler ferdingler added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Nov 7, 2023
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Nov 10, 2023
Copy link

This issue has been automatically locked.

@github-actions github-actions bot added the archived This issue has been locked. label Nov 14, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Nov 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived This issue has been locked. closed-for-staleness pending-triage response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants