Hello, i have a little problem with cors policy settings. Everytime i login in, i get errors below. ...
j
Hello, i have a little problem with cors policy settings. Everytime i login in, i get errors below. Backend is written with expressjs, front end with react.
r
hey! It's cause you are using origin
*
j
i tried using many options, nothing worked for me. Here are the errors, no matter what option i choose, they are always like this.
r
is the CORS middleware after or before supertokens middleware?
j
after, first i init the supertokens and then i use cors
r
reverse it
put cors before the supertokens middleware
j
now it doesnt even run
after the switch
r
first superotkens.init, then cors middleware, then supertokens middleware
j
still not working, getting the same error ..
the origin is set correctly though right? when the websitebasepath is /auth
and websitedomain is simply http://localhost
r
set origin to just "http://localhost" (along with the port)
j
nothing has changed
this happens when im using react build static files .. but when i start the development server and navigate to localhost/auth it returns 404
r
can you show me the CORS error again?
and the network tab
j
sure a sec
r
can you enable the backend debug log and then call the sign in API?
j
okay, the cors error is gone but now i get this one, maybe i have something wrong with my nginx configuration
r
can you enable backend debug logs and show me the output of it?
j
r
and the output when you call the API?
j
not sure what do you mean by that
nothing happens
when i try to log in, the api doesnt log anything else
r
right.. so it means it's not even hitting the supertokens middelware
yea.. not sure why that would be happening
maybe something wrong with your setup ingeneral
j
yeah, i guess the nginx is not setup correctly
r
most likely
j
any idea why this happens? it looks like it appends one /api before the call ..
r
Cause you have set apiGatewayPath to /api
And apiBasePath to that as well
j
or do you mean on the frontend?
should i remove the /api from the apiBasePath (frontend)? -- well yeah that just makes that it doesnt even reach the backend
okay fixed with removing apiGateWayPath on backend and changing apiBasePath to /api/auth
r
Cool!
8 Views