https://supertokens.com/ logo
Title
c

Chunkygoo

10/04/2022, 5:35 AM
cookie domain
I noticed two weird behaviors
When I do not specify a cookie domain, and when I try to make an api call to a protected route, the site gets into a refresh loop
This also happens if domain is set but samesite=none
`export async function getServerSideProps(context) { let cookieString = ''; for (var key of Object.keys(context.req.cookies)) { cookieString += key + '=' + context.req.cookies[key] + '; '; } try { let myAxios = await myAxiosPrivate(); var res = await myAxios .get(
/users/me
, { headers: { Cookie: cookieString, }, }) .catch((e) => { return e.response; }); if (res.status === 401) { return { props: { fromSupertokens: 'needs-refresh' } }; } return { props: { _res: { data: res.data, status: res.status }, }, }; } catch (error) { console.log(error); } }`
This code always return { props: { fromSupertokens: 'needs-refresh' } };
Once it gets a new accesstoken/refreshtoken pair, it refreshes again
r

rp

10/04/2022, 5:45 AM
have you added interceptors to axios?
c

Chunkygoo

10/04/2022, 5:50 AM
Yes
If I add cookie domain = ".myapp.info", the first error goes away
@nkshah2
n

nkshah2

10/04/2022, 6:12 AM
Can you enable debug logs on the frontend and backend and post the output here? (The docs have a troubleshooting section explaining how)
c

Chunkygoo

10/04/2022, 6:18 AM
ok I will do that tomorrow and get back to you