Next.js Discord

Discord Forum

NextJS CORS Header OAuth Issue

Unanswered
Asiatic Lion posted this in #help-forum
Open in Discord
Avatar
Asiatic LionOP
It seems when I use NextResponse.redirect("https://site.com/api/v1/auth/login), it adds a number of headers that are passed to the oauth provider, but not allowed by the OAuth provider (in this case discord's) CORs rules. How can I fix/prevent the headers from being passed here, as looking at the request it contains the following:
access-control-request-headers: next-router-prefetch,next-router-state-tree,next-url,rsc

Error Message in console:
https://discord.com/api/oauth2/ (redirected from 'https://site.com/api/v1/auth/login') from origin 'https://site.com' has been blocked by CORS policy: Request header field next-router-state-tree is not allowed by Access-Control-Allow-Headers in preflight response.


which in turn leads to Failed to fetch RSC payload

1 Reply

Avatar
Asiatic LionOP
Bump