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.

Nuxt: Login through auth0 doesn't redirect to localhost

See original GitHub issue

Current behavior

I created a simple test that checks if the home page redirects to a specific route:

describe('Open Artwork page', () => {
  it('should display the title', () => {
    cy.visit('http://localhost:3000/')
    cy.contains('Artwork').should('be.visible');
  });
});

The user has to login in with Auth0 to access the home page. This is the login command:

Cypress.Commands.add('login', () => {
  const environment = Cypress.env("ENV")
  const tenantName = environment === 'development'
    ? 'artbeat-venture'
    : `artbeat-venture-${environment}`

  const args = {
    email: Cypress.env()[environment]['username'],
    password: Cypress.env()[environment]['password'],
    environment,
    tenantName,
  }

  cy.session(args, () => {
    const { tenantName } = args

    cy.origin(
      `https://${tenantName}.eu.auth0.com`, { args },
      ({ email, password, environment, tenantName, baseUrl }) => {
        cy.visit({
          url: `https://${tenantName}.eu.auth0.com/authorize`,
          qs: {
            client_id: Cypress.env()[environment]['clientId'],
            response_type: "token",
            redirect_uri: `http://localhost:3000`,
          },
        })
        cy.get('#username').type(email)
        cy.get('#password').type(password)
        cy.get('button').contains('Continue').click();
      })
    // assert we've returned to the site
    cy.url().should('contain', '/artwork') // todo: check this
  })
})

We run the login command on the beforeEach:

beforeEach(function () {
  cy.login()
})

We are able to run the test locally with the standard npm run dev (vue app). Screenshot 2022-08-16 at 13 44 55

The github action pipeline is the following and we are not able to run the tests. It looks like after the login cypress cannot redirect to localhost:3000. This is our yml file:

 cypress-run:
    name: Run E2E tests
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Setup node
        uses: actions/setup-node@v2
        with:
          node-version: 14

      - name: Cypress run
        uses: cypress-io/github-action@v4
        with:
          cache-key: hash-${{ hashFiles('package-lock.json') }}
          build: npm run build
          start: npm run start
          wait-on: http://localhost:3000
          command: npm run cypress-run:staging

      - name: Archive e2e artifacts
        id: artifacts
        uses: actions/upload-artifact@v2
        if: failure()
        with:
          name: e2e
          path: |
            cypress/videos/
            cypress/screenshots/

The test is stuck with a blank page, even with longer timeout (30 mins): should display the title -- before each hook (failed)

I also tried locally with the same github action setup aka:

npm run build
npm run start
npm run cypress-run:staging

and it works.

We checked the logs from auth0 and we receive a successful Login Confirmation message from the logs so I assume the issue is on a cypress level. Maybe it’s a chrome configuration on github.

Thanks in advance!

Desired behavior

The desired behavior is that the app is able to load the homepage after the auth0 redirect on localhost:3000

Test code to reproduce

I can’t provide a repository as my app login is bounded through an auth0 clientId

Cypress Version

10.4.0

Node version

v14.19.1

Operating System

macOS 12.2.1 locally, ubuntu on github

Debug Logs

No response

Other

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
emilyrohrboughcommented, Sep 6, 2022

@nicoladl Great! Thanks for clarifying.

1reaction
nicoladlcommented, Sep 6, 2022

It is definitely an issue with the nuxt build. I’m just leaving a message to posterity.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Redirect To for classic login doesn't work
Hello there, I tried setting the Redirect To url for password reset and verification email for our classic login, but it doesn't work, ......
Read more >
App infinitely redirecting after login
I have a user that is being infinitely redirected in our app. The webpage loads auth0, shows a pop up, then redirects the...
Read more >
General
My application is deployed on google cloud, and login is complaining access_denied : Password login via OIDC-conformant clients with ...
Read more >
Redirect_uri seems to be wrong
Hi, Please see the application I have setup in " Salesforce OpenId Connect 2" app for authenticating users login from salesforce application ...
Read more >
checkSession always return 'login_required' on localhost
I am not using any third parties social connection, just auth0.WebAuth for login with my own login page. Is there anything that prevents...
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