-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Error while setting up the middleware - withAuth / getToken #5105
Comments
Since you are using Middleware, I assume you forgot to set The logs should give you more details about the configuration error. |
Also, keep in mind that Next.js currently has an upstream bug in |
It looks like this issue did not receive any activity for 60 days. It will be closed in 7 days if no further activity occurs. If you think your issue is still relevant, commenting will keep it open. Thanks! |
To keep things tidy, we are closing this issue for now. If you think your issue is still relevant, leave a comment and we might reopen it. Thanks! |
I am also get the same error: Server error There is a problem with the server configuration. `export { default } from 'next-auth/middleware'; // If the user is not siggned in it will go direct '/auth/signin' I want to redirect the user to signin page if he is not signed in. |
same issue with me how to fix this ? |
I have the same issues, how could I fix this? as it should redirect to api/aut/signin http://localhost:3000/api/auth/error?error=Configuration having this issue. |
this is a solution export default withAuth( ) export const config = { matcher: ["/"]} |
Environment
System:
OS: Windows 10 10.0.22000
CPU: (4) x64 Intel(R) Core(TM) i5-6600K CPU @ 3.50GHz
Memory: 17.66 GB / 31.91 GB
Binaries:
Node: 16.13.2 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
npm: 8.1.2 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.22000.120.0)
Internet Explorer: 11.0.22000.120
npmPackages:
next: latest => 12.2.3
next-auth: ^4.10.3 => 4.10.3
react: 18.1.0 => 18.1.0
Reproduction URL
https://github.com/dawidseipold/melsea
Describe the issue
Hi! I have a problem with setting up the middleware for the next-auth.
No matter what I put inside of the
withAuth
function, I get the same error whenever I go to a configured matching route.GET http://localhost:3000/api/auth/error?error=Configuration 500 (Internal Server Error)
The code above is just an example of what I've tried, but the same error occurs even if I do it like this:
Throughout the whole app I retrieve the token with a
getSession
function, which cannot be used in the middleware. From what I read you can usegetToken
function as an alternative, however that also doesn't work for me, as I get the same error as described here, when I use this code:All of that makes me believe that I might've setup something wrong inside of the
[...nextauth].ts
file, but can't really point it out myself. My guess is that I', probably juggling around betweenjwt
anddatabase
session strategy, which would explain the lack of the token (I might be wrong though).[...nextauth].ts
How to reproduce
[...nextauth].ts
as abovemiddleware.ts
as aboveExpected behavior
If the user is not authorized by Spotify they should be redirected by middleware into
'/login'
route. If they are however, they should be able to use the other routes.The text was updated successfully, but these errors were encountered: