https://supertokens.com/ logo
p

pepegc

03/30/2022, 4:56 PM
Trying to make a request to my backend but getting back unauthorized. I understand cookies are sent automatically? I previously successfully received the cookies in the response headers of
signup/code/consume
. Also using
'Access-Control-Allow-Credentials': true
on my request to the backend. What am I missing? After receiving the cookies from
signup/code/consume
I should see the cookies on dev tools>storage>cookies, correct? because I don't. Btw, I'm using
fetch
, not
axios
r

rp

03/30/2022, 5:15 PM
Trying to make a request to my backend but getting back unauthorized. I understand cookies are sent automatically? I previously successfully received the cookies in the response headers of
signup/code/consume
. Also using
'Access-Control-Allow-Credentials': true
on my request to the backend. What am I missing? After receiving the cookies from
signup/code/consume
I should see the cookies on dev tools>storage>cookies, correct? because I don't. Btw, I'm using
fetch
, not
axios
Can I see the request headers of the API call?
No cookies are being sent. Nor is interception happening
What’s the domain you are querying? And what is the appInfo object set to on the frontend and backend?
p

pepegc

03/30/2022, 5:18 PM
I'm querying from my frontend at
https://localhost:3000/
my backend (FastAPI) at
https://acheron-api.herokuapp.com/
r

rp

03/30/2022, 5:18 PM
Https? And not http?
What’s ur appInfo object?
p

pepegc

03/30/2022, 5:19 PM
both https... I'm not doing anything to appInfo on the frontend
on the backend I'm loading standard values
from an .env...
r

rp

03/30/2022, 5:20 PM
So on the frontend, what’s your apiDomain value?
And what are the .env values for the above?
p

pepegc

03/30/2022, 5:21 PM
those are fine, if I take out the validation at the backend api I get the resposne
I think this is the culprit, but idk how to send them
r

rp

03/30/2022, 5:27 PM
Are you calling supertokens.init before using
fetch
? Are you using
node-fetch
or the browser's inbuilt fetch?
What are the response headers in the sign in API?
p

pepegc

03/30/2022, 5:28 PM
yes, and no. it's sveltekit's fetch.. but just normal fetch for this matter
r

rp

03/30/2022, 5:29 PM
I mean, are you importing fetch from somewhere and using that?
Cause i don't think that will work. On the client side, you should use
window.fetch
.
p

pepegc

03/30/2022, 5:33 PM
I'm not importing fetch.. I'm using the default one on a .js file
r

rp

03/30/2022, 5:33 PM
Hmmm
p

pepegc

03/30/2022, 5:33 PM
now not sure what I did but I'm no longer getting the sign response, recognize the reason for this error?
r

rp

03/30/2022, 5:34 PM
That’s probably an error in how you are sending email / sms. The callback function you implemented is throwing that error
p

pepegc

03/30/2022, 5:36 PM
yea I think I have it, 1 sec, rebuilding
r

rp

03/30/2022, 5:39 PM
Ok. This seems fine
p

pepegc

03/30/2022, 5:39 PM
now it's working, had a retard 'await' while requesting the email in the backend. See? I'm getting the cookies
but they are not 'sticking'
r

rp

03/30/2022, 5:40 PM
So two things: - The cookies are attached to the api domain, but you are viewing the website domain's cookie store. - Im sure that the interceeptors are not being applied to
fetch
and thats' why things are not working
p

pepegc

03/30/2022, 5:41 PM
ignore the 'token' there
r

rp

03/30/2022, 5:41 PM
In the
.then
of fetch, can you call
await supertokens.doesSessionExist()
?
And see what that prints out
p

pepegc

03/30/2022, 5:51 PM
I can't use it there, it says SuperTokens is undefined. that's a
api.js
utility
r

rp

03/30/2022, 5:51 PM
Right. Are you calling supertokens.init on the frontend?
p

pepegc

03/30/2022, 5:52 PM
yes.. I'm calling it on the layout file for all routes
r

rp

03/30/2022, 5:52 PM
So this fetch, is it called on server side or client side?
p

pepegc

03/30/2022, 5:52 PM
client side, on mount
r

rp

03/30/2022, 5:53 PM
Cause if it’s the client side, you can import supertokens from supertokens-website and call that function in the .then
p

pepegc

03/30/2022, 5:53 PM
SuperTokens is init'd client side, on mount
r

rp

03/30/2022, 5:56 PM
Right. So you should be able to call supertokens.doesSessionExist in the .then of the fetch?
p

pepegc

03/30/2022, 5:59 PM
it's returning false
tested it somewhere else
after signin and getting something like this
r

rp

03/30/2022, 6:02 PM
Are you sure that supertoeks.init is being called before calling fetch?
Maybe it would be a good idea to get on a call to debug this
p

pepegc

03/30/2022, 6:03 PM
yes I even tried to initing right before the fetch
happy to get on a call, I'm super lost with frontend dev and I think sveltekit, despite all its magic, might be making things harder
r

rp

03/30/2022, 6:04 PM
Yeaaaa. Fair. Can you please book a slot using the link on our site
On the landing page, you can find the link with “consult an expert”
p

pepegc

03/30/2022, 6:06 PM
yes, but damn the soonest is tmrw at 2pm
(local)
r

rp

03/30/2022, 6:07 PM
Well. Yeaaa.
p

pepegc

03/30/2022, 6:07 PM
will take that one, thanks 😄
took the one at my 5am
r

rp

03/30/2022, 6:14 PM
Oh wow.
7 Views