Next.js Discord

Discord Forum

serverside redirection causes cors error in Oauth2

Unanswered
Burmese posted this in #help-forum
Open in Discord
BurmeseOP
I am using appwrite to generate a url for user authentication (Oauth2).
after the redirect url is made and i try to redirect the user to the generated url, i get CORS error in the console.
how do i add my server's origin in the auth provider's allowed origins?

if(providerid === "google"){ authurl = await account.createOAuth2Token( OAuthProvider.Google, "http://localhost:3000/createSession", "http://localhost:3000/unexpected" ); } if(authurl !== "") return NextResponse.redirect(authurl) return NextResponse.json({ message: "signup Failed", success: false, authurl, });

1 Reply

BurmeseOP
This is the CORS Error:


Access to XMLHttpRequest at 'https://accounts.google.com/o/oauth2/v2/auth?client_id=64278655-.......' (redirected from 'http://localhost:3000/api/users/signup') from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.