Open v-krupsky opened 1 month ago
I've checked the proposed fix (withCredentials=true) by modifying http package source to make bool withCredentials = true; and it does solve the issue. Browser stores the cookie, it appears in requests to the API.
hi @TheNoumanDev Ivan found an important issue with handling cookies from different domains that we should resolve. The http
flutter package we use does not support it. So we either use a different package or enhance it a bit to support it.
Here's a long discussion on this and a neat solution someone provided
We basically need to do two things -
withCredentials
(default: false) in our API
definition. Read that (if set) to set the value of withCredentials
allowCrossDomainCookies
. when set to true, it will automatically set withCredentials
to true for all API calls. That way user doesn't have to remember to set it everytime.
Context: if a cookie is provided by the API requested from Ensemble, it is not stored by the browser.
Sample request and response headers are below (body does not matter). Flutter web being run on port 9000. FastAPI BE being run on port 8000.
Request headers:
Response headers:
Suggestion: extend manageCookies from issue https://github.com/EnsembleUI/ensemble/issues/1649 for web apps to the following behaviour: When manageCookies is true, include withCredentials = true when making API requests.
Plain JS example: fetch('https://example.com/', { credentials: 'include' });