msw icon indicating copy to clipboard operation
msw copied to clipboard

MSW breaks Auth0 (via express-openid-connect) redirects - Endless browser load

Open awacode21 opened this issue 1 year ago • 6 comments

Prerequisites

Environment check

  • [X] I'm using the latest msw version
  • [X] I'm using Node.js version 14 or higher

Browsers

Chromium (Chrome, Brave, etc.)

Reproduction repository

https://codesandbox.io/p/github/awacode21/reproduction-vue-ssr-auth0-msw-bug/msw-issue

Reproduction steps

  1. run npm install

  2. run npm run dev

  3. within preview, try to click login button. -> browser will endlessly load

  4. stop project

  5. comment out MSW

  6. start project again, login link to Auth0 will do the redirect.

Current behavior

This is about a Problem Mock Service Worker is producing when try to use Auth0 on server middleware with express-openid-connect.

Once you try to login or logout, so that the redirect to auth0 would happen the browser stucks in endless load.

This does not happen without Mock Service Worker. Then auth0 is working perfectly fine. So it seems to be related to Mock Service Worker. I also found a related issue on auth0/nextjs-auth0 where a user is reporting the same problem but within another setup: https://github.com/auth0/nextjs-auth0/issues/606

"Debugging shows the last event to have successfully cloned a request to /.well-known/openid-configuration, but then hangs after the event closes. Any ideas on what could be causing this? Underlying got client?"

Honestly this problem is a real big issue for my current customer project. If we are not able to solve it we will need to move away from MSW, as changing the AUTH0 approach is no option. But i would like to prevent that move.

I really would appreciate help/fix on this. Best regards, Annick

Setup Info: Vite, Vue 3, SSR, AUTH0 with express-openid-connect as Server middleware, Mock Service Worker (node version for server, browser version for browser)

Expected behavior

MSW should not have a problem. Redirect to Auth0 via express-openid-connect should work as expected.

awacode21 avatar Nov 18 '22 12:11 awacode21