-
Notifications
You must be signed in to change notification settings - Fork 427
Closed
Labels
questionFurther information is requestedFurther information is requested
Description
Description
Provide a clear and concise description of the issue, including what you expected to happen.
Issue: When MSW is running on next.js, users are unable to login to the application locally.
Expected: When MSW is running on next.js, users should be able to login to the application locally.
Reproduction
- Setup a next.js auth0 repo
- Add the setup from the next.js msw repo
- When a user logs in, they get
Cannot read properties of undefined (reading 'content-encoding')
shown on the page.
wait - compiling /api/auth/[...auth0]...
event - compiled client and server successfully in 57 ms (214 modules)
error - unhandledRejection: TypeError: Cannot read properties of undefined (reading 'content-encoding')
HandlerError [RequestError]: Cannot read properties of undefined (reading 'content-encoding')
at new HandlerError (xxx/app/node_modules/@auth0/nextjs-auth0/dist/utils/errors.js:53:28)
at Object.<anonymous> (/xxx/app/node_modules/@auth0/nextjs-auth0/dist/handlers/login.js:35:31)
at step (xxx/app/node_modules/@auth0/nextjs-auth0/node_modules/tslib/tslib.js:143:27)
at Object.throw (xxx/app/node_modules/@auth0/nextjs-auth0/node_modules/tslib/tslib.js:124:57)
at rejected (xxx/app/node_modules/@auth0/nextjs-auth0/node_modules/tslib/tslib.js:115:69)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
code: 'ERR_GOT_REQUEST_ERROR'
}
error - unhandledRejection: TypeError: Cannot read properties of undefined (reading 'content-encoding')
The issue is immediately remedied by turning off MSW. Even if MSW doesn't have any handlers, nextjs-auth0 still seems to break.
It looks like it's the callback request(?)
const { setupWorker } = require('msw');
const { setupServer } = require('msw/node');
if (typeof window === 'undefined') {
const server = setupServer();
server.listen({ onUnhandledRequest: 'bypass' });
} else {
const worker = setupWorker();
worker.start({ onUnhandledRequest: 'bypass' });
}
Environment
Please provide the following:
- Version of this library used:
1.7.0
- Version of the platform or framework used, if applicable:
next: 12.1.0
- Other relevant versions (language, server software, OS, browser):
Mac OS
Chrome
Firefox
- Other modules/plugins/libraries that might be involved:
MSW
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested