3

I have a backend based on the FARM stack by MongoDB (https://www.mongodb.com/developer/how-to/FARM-Stack-FastAPI-React-MongoDB/), with authentication (https://www.mongodb.com/developer/how-to/FARM-Stack-Authentication/).

FAST API Doc Authentication works as it should on Fast API docs and Postman. When executing a successful user log in, it automatically sets the JWT HttpOnly cookie on the browser. When logged in, it removes the cookie again on logout.

When calling /login on front-end, it said following error in the Network tab: Error

As the error states, I managed to fix this by setting the cookie options on the backend as following, and I could afterwards successfully login from a react front-end: FARM STACK BACKEND

Unfortunately, this doesn't work for the /logout call. This error occurs again, as the SET-COOKIE header tries to set an empty cookie, yet it can't due to the cookie having a SAMESITE="lax" as default, but I don't see a way to find out how to configure it for the /logout call in the backend.LOGOUT Network

My front-end /logout call looks like this, the same as /login:

FRONTEND CALL

How do I configure my front-end/back-end, so my front-end can successfully delete my cookie and successfully log out?

0 Answers0