capacitor with mobile app header dont add cookies, becasue diffrent url :/, how to fixed this app u...
p
capacitor with mobile app header dont add cookies, becasue diffrent url :/, how to fixed this app url
Copy code
'capacitor://localhost',
    'ionic://localhost',
    'http://localhost',
    'capacitor://',
but api
api.xx.com
for some reason it doesn't add any cookies when leaving this backend ss
In the backend, all cors settings and connection are gone, but no cookies are added
this login working
and cookies
but graphql dont add cookies
r
You need to use the same domain as apiDomain for graphql queries as well
Alternatively, if you really can’t figure this out, wait for a few weeks. We will release non cookie based auth which will make all this simpler.
p
Are you considering using Redis ?
Interesting but all the data is in the database
r
We aren’t. The access token verification is stateless anyway. So it’s very fast
p
hmm this is impossible on mobile so cookies never dont go ?
mobile
ionic://localhost
, api :
api.xx.com
the only possibility will be to send the access token jwt in the header.
r
Right. Yea.
p
So how are customers sending it now ? in mobile app
r
For capacitor app? They r customising the backend to allow non cookie based auth.
p
Now it all fell into place.
Then we will wait 1-2 weeks.
Thank you
I sent the cookies in the backend like this, can I put it back in the cookies in the backend?
But I guess that would be a security hole
r
You can send it. But these cookies are not accessible via the frontend JS cause they are httpOnly. So no point doing this anyway. I would recommend that you wait until we release the features.
p
cc: @robschilder
r
@productdevbook what is the apiDomain you set in the mobile app?
You need to set the same api domain in which you are sending the request to. This will make our frontend SDK add the cookies to that domain.
I’m not sure why you are facing so many issues. Maybe some misunderstanding or unclear docs. I think it would be useful if you explain your setup clearly. What is the address your api layer is listening on, what clients do you have and what’s their domain, what url are each of your clients using to query the backend, and what is your current supertokens.init on each of the clients and the backend.
p
.
Since we are using a capacitor, they connect with the local url, cookies do not go to the api address because there is a website.
r
Can you give me specific values for everything? I’m having a hard time understanding your setup
p
api :
http://192.168.1.103:3001
local api: production:
https:api.xx.com
capacitor web url client:
Copy code
'capacitor://localhost',
    'ionic://localhost',
    'http://localhost',
    'capacitor://',
client Supertokens
apiDomain
add
websiteDomain: 'xx.xx.xx'
// NOTE: this is the same as the appId in the capacitor.config
r
I really don’t understand.
Can you rewrite in a clear way?
If you can’t make it clear, it’s going to be very hard to help.
p
Capacitor application starts at these urls.
Copy code
'capacitor://localhost',
    'ionic://localhost',
    'http://localhost',
    'capacitor://',
r
What are these?
Shouldn’t the app start at just one URL?
p
capacitor opens in a browser, these are their addresses, such an address is opened in android and ios
r
So each of these urls is for each of the clients?
Can you tell label them clearly? Which type of client has which address?
p
this used ?
app open chome or safari android and ios
and url
Copy code
'capacitor://localhost',
    'ionic://localhost',
    'http://localhost',
    'capacitor://',
r
Yea so browser I assume it’s http://localhost
But for android, which one is it?
p
one of them is changing
r
@rp_st we are already solving this issue then he can look at the example
Me and nksah
r
Are you and @productdevbook in the same team?
p
no
r
Ah ok. Then please continue @productdevbook
p
Cookies do not go because there is a different address in the api address
exampe
xx.xx.com
r
Your being vague again
p
because dont same url
r
I can’t help like this
I need to know specific urls and the setup
Which client has which url and queries which api
p
Don't both client and server have to be the same address for cookies to go?
r
No. They don’t
Cookies are attached to the api domain only
p
But apollo client only added the cookies when it's the same address, it doesn't add it when it's different. I will examine a little more
r
What’s the configured apiDomain and websiteDomain on the backend?
p
apiDomain: 'http://localhost:3001', websiteDomain: 'http://localhost:3000',
r
Right. So this means that the cookie same site value is lax
What’s the frontend url of your app?
Is it localhost or something else?
p
VITE_GRAPHQL_ENDPOINT=http://192.168.1.103:3001/graphql VITE_API_DOMAIN=http://192.168.1.103:3001
no
Isn't the error from here?
r
So this is a misconfiguration, but this is not why it’s not working
What’s the frontend url of the app?
Is it http://localhost or something else entirely?
p
http://localhost:3100/ this capacitor
r
And what’s the apiDomain that you configured on the frontend?
p
http://192.168.1.103:3001 -> this supertokens
r
Ok. So this is why the cookies are not being sent.
On the backend, you should set the correct apiDomain
p
backend supertoken settings
r
You set the apiDomain to localhost:3001 on the backendc but on the frontend, you set it to 192.168…. Set the same value on both frontend and backend
p
fixed, thank you ❤️ 🤦‍♂️
r
Ok nice
p
I will test it on mobile phone and make a return
local emulator working, android test
14 Views