How to use cookie based authentication in a react application? #1378
Unanswered
Sharjeel50
asked this question in
Q&A
Replies: 1 comment
-
Several things to check:
cookie_transport = CookieTransport(cookie_name="fastapi-user-auth-token", cookie_max_age=3600, cookie_secure=False) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In the backend I am using a cookie transport and JWT strategy -
Registering, logging in & getting the current user is working fine when calling the endpoints the open API docs and the cookie is set correctly from what I can see in the Chrome console, but when attempting the same in my react application, I get
unauthorized
errors as the cookie is not being sent, here is some example code -Calling
/auth/jwt/login
initially responds with status code204
but does successfully set thefastapi-user-auth-token
cookie which I can see in the console, but when calling/users/me
I get an unauthorized error, I can see in the request headers that no cookie is being sent, am I missing something?Below is my backend -
users.py
router.py
main.py
Beta Was this translation helpful? Give feedback.
All reactions