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

withMiddlewareAuthRequired on Next.js 13 throws 'req.cookies.keys is not a function' #892

Closed
7 tasks done
wjrogers opened this issue Nov 1, 2022 · 2 comments
Closed
7 tasks done
Labels
beta needs investigation This needs to be investigated further before proceeding

Comments

@wjrogers
Copy link

wjrogers commented Nov 1, 2022

Checklist

  • The issue can be reproduced in the sample app (or N/A).
  • I have looked into the README and have not found a suitable solution or answer.
  • I have looked into the examples and have not found a suitable solution or answer.
  • I have looked into the API documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Description

I am experimenting with the v2 beta on Next.js 13. I added middleware to my project following the examples in #815, and the server raises an error trying to read the request cookies:

at MiddlewareCookies.getAll (webpack-internal:///(middleware)/./node_modules/@auth0/nextjs-auth0/dist/utils/middleware-cookies.js:18:39)
    at CookieStore.eval (webpack-internal:///(middleware)/./node_modules/@auth0/nextjs-auth0/dist/auth0-session/cookie-store.js:128:54)
    at step (webpack-internal:///(middleware)/./node_modules/tslib/tslib.es6.js:130:23)
    at Object.eval [as next] (webpack-internal:///(middleware)/./node_modules/tslib/tslib.es6.js:111:53)
    at eval (webpack-internal:///(middleware)/./node_modules/tslib/tslib.es6.js:104:71)
    at new Promise (<anonymous>)
    at Module.__awaiter (webpack-internal:///(middleware)/./node_modules/tslib/tslib.es6.js:100:12)
    at CookieStore.read (webpack-internal:///(middleware)/./node_modules/@auth0/nextjs-auth0/dist/auth0-session/cookie-store.js:122:24)
    at SessionCache.eval (webpack-internal:///(middleware)/./node_modules/@auth0/nextjs-auth0/dist/session/cache.js:20:63)

I understand this is all very new. Thanks for your work on implementing middleware support!

Reproduction

  1. Configure Auth0 (e.g. using the sample app)
  2. Install next@13.0.1
  3. Add a middleware.ts to the project:
    import { withMiddlewareAuthRequired } from "@auth0/nextjs-auth0/middleware";
    
    export default withMiddlewareAuthRequired();
  4. Run the server and load a page in the browser

SDK version

2.0.0-beta.1

Next.js version

13.0.1

Node.js version

16.18.0

@adamjmcgrath
Copy link
Member

Thanks for raising @wjrogers

This looks like it's caused by a breaking change in next@13.0.1 from vercel/next.js#41526

You should be able to use next@13.0.0 while we investigate

@adamjmcgrath adamjmcgrath added the needs investigation This needs to be investigated further before proceeding label Nov 2, 2022
@adamjmcgrath
Copy link
Member

This is fixed in https://github.com/auth0/nextjs-auth0/releases/tag/v2.0.0-beta.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta needs investigation This needs to be investigated further before proceeding
Projects
None yet
Development

No branches or pull requests

2 participants