Problems with refreshtoken cookie path in nextjs13 server side rendering
I am using nextjs13 SSR and a fastapi backend.
When I render something in server in nextjs I send the accestoken and everything works fine.
When my accestoken is expired I call my refresh endpoint. The problem is that I don't have the refreshToken cookie because is only for /myrefreshendpoint.
How can I fix it?
Is any way to make this cookie available for all paths? Is that secure?
Thanks for reading!
r
rp_st
06/23/2023, 6:06 PM
Hey.
rp_st
06/23/2023, 6:06 PM
See our docs for NextJS SSR
rp_st
06/23/2023, 6:06 PM
you need to send back a response to the client which tells it to call the refresh API and then reload the page
s
santimnv
06/24/2023, 4:20 PM
I have been looking at it for a while, seems like a bad solution to achieve something that could be done by changing a cookie path
santimnv
06/24/2023, 4:21 PM
How can I change the cookie path? Is that secure?
santimnv
06/24/2023, 4:22 PM
Also, as I see your solution totally breaks the SSR lifecycle because all pages are using the useEffect hook
r
rp_st
06/24/2023, 6:42 PM
Changing the refresh cookie path is a security issue.
rp_st
06/24/2023, 6:43 PM
What do you meant by breaks the SSR lifecycle? Using useEffect doesn’t break SSR