Skip to content

Facing Error: Exceeded maxRedirects. Probably stuck in a redirect loop #20416 #21

Description

@SriKKP

Hi,

I have cypress UI tests running successfully until few days ago when our authentication team has made a change that redirects the page twice, previously only once. This change has caused my tests to fail at cy.visit('/') with error

"We attempted to make an http request to this url but the request failed without a response
https://mybetawebsite/
We received this error at network level
Error: Exceeded maxRedirects. Probably stuck in a redirect loop https://mybetawebsite/redirect=signin&redirect=signin
at processRedirect (/private/var/folders/.........../Cypress.app/Contents/Resources/app/packages/server/node_modules/@cypress/request/lib/redirect.js:104:24..........."

When I asked them about this error, they told me to follow the redirect a second time.
"Just follow the same redirects a second time. You'll need to update your tests to follow the redirects a second time over."

I know cy.visit follows redirects (https://docs.cypress.io/api/commands/visit#Redirects) , but it does only once or multiple times?

Previously, when my tests were passing, I could see 302(redirection) at cy.visit (to different url for auth) and test used to continue and pass.

in my cypress.json, baseUrl: https://mybetawebsite/

How do I handle second redirect?

I have tried
1.increasing redirectionLimit in cypress.json (dinot work),
2. cy.intercept , but I cannot mention a url to redirect to because it is dynamic and comes from the another team
3. cypress retries ( i don't think this is the solution and it didnot work either)

the "if(self.redirectsFollowed >= self.maxRedirects)" in node_modules/@cypress/request/lib/redirect.js:104:24 is generating the issue. But how do I increase this maxRedirects

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions