Remove httponly from cookie when making HTTP call using Flutter

264 views Asked by At

I have an Express application that has a cookie-based authenticated route. I am using cookie-session to store auth tokens in the cookie.

I am developing a mobile app using Flutter and am using the requests package to manage cookies while making HTTP calls. I am able to make basic HTTP GET and POST calls.

My Express application has two routes - Sign In and Get Info. The route to Sign In authenticates the user and sets an auth token in the cookie using cookie-session. The Get Info gets information for an authenticated user, and the authentication is checked by a middleware.

The Express application is working as expected when I make calls using Postman or curl but is failing when I make calls using Flutter.

When I analysed the differences, I found that the Flutter application is adding an 'httponly' in the cookie, and consequently, the auth tokens are not being extracted. When making the same call using curl, it failed with httponly and worked when I removed the httponly flag in the cookie.

I tried toggling httponly in cookie-session by using sessionOptions and it has not worked.

Can someone help me out on this? I would be happy to provide additional information if it is required.

0

There are 0 answers