If the supetoken-core is running in docker, How to...
# support-questions
p
If the supetoken-core is running in docker, How to allow cors origin? I am getting this error - "from origin 'http://localhost:3001' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'."
r
If the supetoken-core is running in docker, How to allow cors origin? I am getting this error - "from origin 'http://localhost:3001' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'."
You need to add CORS setting to your backend API layer. The frontend should never query the core directly.
From the quick setup > backend guide
p
backend is a digital ocean instance and supetoken -core is installed on it in caprover . Running inside docker container.
Have done this
await NextCors(req, res, { methods: ["GET", "HEAD", "PUT", "PATCH", "POST", "DELETE"], origin: "http://localhost:3001", credentials: true, allowedHeaders: ["content-type", ...supertokens.getAllCORSHeaders()], });
r
Is your frontend also on localhost:3001?
and your backend on localhost:3001 as well?
p
yes frontend is on localhost:3001 and backend domain of caprover is at "http://xyzsupertoken.xyz.com"
r
the backend domain for supertokens core doesn't matter since that should never be queried from the frontend.
then frontend should only talk to your backend API layer
which then talks to the core
p
supetoken-core is installed on top of caprover
r
So what is the domain for your backend APi layer?
is it localhost:3001/api/*?
p
r
but that's where the core is? Or your node code is?
p
wait, getting confused now I have setup a local passwordless demo which run on localhost:3001 connectionURI in backendconfig is. - http://xyzsupertoken.xyz.com - because this is the domain of caprover and supertoken-core is installed over caprover
r
Yes. So your API layer is localhost:3001/api then.
since you are using next.js
so your frontend code which is on localhost:3001/somePath will query localhost:3001/api/auth/* for auth related APIs. And those in turn will query the core running on caprover
So the error that you are getting is when the frontend react code (running on localhost:3001) queries the API layer which is on localhost:3001/api/auth/*) correct?
If not, can i see where the API call is being made to which yields this error?
p
okay, get it when I change the api layer to localhost:3001 then -> I get 500 error How to show the error? quick call?
r
Alright
meet.google.com/ehq-hxxu-ono
p
r
ALso, you should probably add an API key to the core since you are exposing it to the internet.
p
Error: SuperTokens core threw an error for a POST request to path: '/recipe/signinup/code' with status code: 404 and message: Not found
now getting this error
I will add the api_key, for now checking the working
r
What version of the core is deployed?
p
3.5
r
Passwordless recipe doesn't exist in that version. You will need to get core version >= 3.8 for that. I recommend getting the latest version which is 3.10
p
okay
my bad
sorry to ask this again, where can I see which version has which features?
p
fixed those issues, deployed version 3.9... in 3.10 also getting the same error so for now deployed 3.9 that error is gone - {"status":"GENERAL_ERROR","message":"Cannot read property 'status' of undefined"} getting this now in response req - http://localhost:3001/api/auth/signinup/code
r
3.10 should not give you that error.. But OK
Can you send me the full stack trace of the error? And the request being made as well. This indicates that the core isn't replying as expected. Are you sure that the core is deployed correctly?
Cause if i go to this: http://suggaasupertoken.mrine.suggaa.com/apiversion It only gives me the versions as per core version 3.5.. Core version 3.9 or 3.10 should work with more apiversions as seen here: https://github.com/supertokens/supertokens-core/blob/master/coreDriverInterfaceSupported.json
If you see the demo core hosted by us, it gives the folllowing API versions: https://try.supertokens.com/apiversion
p
sure, checking. thanks
r
👍
p
this is the new deployment URL - connectionURI: "http://suggaapwdless.mrine.suggaa.com", it shows the correct api versions Still getting the same error No error logs on console, and even api returns 200 with error message 3rd party email pwd is working fine with this. passwordless throws error cannot read property status of undefined.
r
I think that might be an error in your code for sending the twilio message
You should check that
p
okay
r
That being said, the core and API setup seem fine now! :))
p
thanks... 🙂
4 Views