Hello everyone! I have one question and one issue....
# support-questions-legacy
j
Hello everyone! I have one question and one issue. Issue: - Getting cors error when I try to call createPasswordlessCode, added the cors requirement on node js Question: - I already have session based with firebase and passport session for discord and twitter, could I use this without session?
r
hey @Jota
you mean you want to use supertokens without our session recipe?
j
yes, because I have two logins, one of them with eth wallet
r
i see. You can use our session recipe with other login methods as well
which is what i would recommend you do (easiest solution)
but if you really want to get rid of session recipe, you can override the backend functions to apply your own session logic.
here is a simple example that overrides our session recipe to make it a simple JWT based session: https://github.com/supertokens/supertokens-auth-react/blob/master/examples/with-jwt-localstorage/api-server/index.ts
j
I will try and check if passport and supertokens session don't break each other, thank you
r
alright
j
and cors error, could you help with that?
j
Yeah, I did. This is the error Access to fetch at 'http://localhost:5001/auth/signinup/code' 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. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
r
have you added the cors middleware after or before the supertokens middleware?
j
tried both ways
r
so the CORS middleware should be before the supertokens one
does the OPTIONS API succeed? And the POST one fails? Or the POST one never happens?
j
As soon as I start it returns error on http://localhost:5001/auth/session/refresh
it returns 404
now options is working and post not
now yes, options work and post gives 404
r
You need to set the correct apiBasePath then on the frontend and backend
To match your normal API path
j
yeah, I corrected that, now the OPTIONS call works correctly but the POST returns 404
r
enable backend debug logs and show me the output of the API that returns 404
j
middleware: Not handling because request path did not start with config path. Request path: /auth/signinup/code
could be this?
r
yea
so you need to change the apiBasePath on the frontend to be the correct path
correct base path*
the default is
/auth
j
yeah I changed to the same as the backend one, they are both - apiBasePath: "/vinci-dev-6e577/us-central1/api/auth",
r
so the frontend should be querying
/vinci-dev-6e577/us-central1/api/auth/signinup/code
maybe try building the frontend again?
j
I think the frontend is querying correctly
r
does that base path get stripped away by some reverse proxy server in the middle?
like nginx
j
No, frontend react calling the backend that is deployed on functions on firebase
r
firebase must be removing that base path
change the backend config to be: - apibasePath:
/auth
- apiGatewayPath:
/vinci-dev-6e577/us-central1/api
apiGatewayPath
is another item in the appInfo on the backend
j
now I get Not handling because no recipe matched
r
which recipes have you initialised on the frontend and backend?
j
I had it wrong, already corrected it, and receiving the email
thank you so much 🙂
r
awesomeee!
3 Views