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

Req.cookies.getAll does not exist when using withMiddlewareAuthRequired on next@12 #899

Closed
7 tasks done
Nargonath opened this issue Nov 8, 2022 · 4 comments
Closed
7 tasks done
Labels
beta bug Something isn't working

Comments

@Nargonath
Copy link

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 tried to use the beta withMiddlewareAuthRequired on a next@12.3.2 app but it throws regarding req.cookies.getAll does not exist. I noticed there is a somewhat similar issue (#892). I believe req.cookies.getAll is only available in next@13 which is not mentioned in their documentation. It is not mentioned in the migration guide from v1 to v2 of this library that it breaks compatibility with next@12 though.

IMO the solution is to either bring back retro-compatibility or mention the breaking change in the migration documentation.

Reproduction

I created a repro using the sample app that you can find here: auth0-samples/auth0-nextjs-samples@main...Nargonath:auth0-nextjs-samples:cookies-getall-does-not-exist.

  1. Clone the project locally.
  2. Checkout the cookies-getall-does-not-exist branch.
  3. Run npm ci.
  4. Run npm run dev.
  5. Execute:
curl --location --request GET 'http://localhost:3000/api/protected' \
--header 'Cookie: Cookie_1=value'
  1. Notice the error:
    image

SDK version

2.0.0-beta.2

Next.js version

12.3.2

Node.js version

16.15.1

@Nargonath Nargonath changed the title Req.cookies.getAll does not exist when using withMiddlewareAuthRequired Req.cookies.getAll does not exist when using withMiddlewareAuthRequired on next@12 Nov 8, 2022
@adamjmcgrath adamjmcgrath added the bug Something isn't working label Nov 8, 2022
@adamjmcgrath
Copy link
Contributor

Thanks for raising this @Nargonath

Yep, I thought the fix for Next 13.0.1 would only drop support for 13.0.0 (not 12) - my bad. Will add something back for 12 in the next beta update - in the meantime you can use 2.0.0-beta.1 (or Next 13.0.1)

@Nargonath
Copy link
Author

Alright, thanks @adamjmcgrath for the fast answer.

@adamjmcgrath
Copy link
Contributor

@Nargonath
Copy link
Author

Perfect, thank you @adamjmcgrath

FPiety0521 pushed a commit to FPiety0521/Auth0-Next.js-SDK that referenced this issue Apr 28, 2023
redsky030428 added a commit to redsky030428/autho_next.js that referenced this issue May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants