Do you plan for support Cookie manager in web?
No, cookies are automatically managed by the browser
No, cookies are automatically managed by the browser
Use flutter web to develop websites, and background services use golang, but cookies cannot always be set automatically when I request an interface. The headers returned by dio printing in flutter are only Content-Type and Content-Length, but in the browser developer mode, There is a Set-Cookie option in the Response header. The cookie-manager with the dio plug-in also has no effect. How to solve this situation?



I solved this problem.
BaseOptions options = new BaseOptions(
baseUrl: _baseUrl,
connectTimeout: 10000,
receiveTimeout: 5000,
headers: {
"Accept": "application/json",
},
);
DioForBrowser _d = DioForBrowser(options);
var adapter = BrowserHttpClientAdapter();
// This property will automatically set cookies
adapter.withCredentials = true;
_d.httpClientAdapter = adapter;
_d.get("http://localhost:1234/login...")
My original comment was it did not work but i was mistaken. It does. the thing is, withCredentials is required in order for cookies to be written to browser.
Shouldnt the default dio object have this property? instead of having to use DioForBrowser?
I solved this problem.
BaseOptions options = new BaseOptions( baseUrl: _baseUrl, connectTimeout: 10000, receiveTimeout: 5000, headers: { "Accept": "application/json", }, ); DioForBrowser _d = DioForBrowser(options); var adapter = BrowserHttpClientAdapter(); // This property will automatically set cookies adapter.withCredentials = true; _d.httpClientAdapter = adapter; _d.get("http://localhost:1234/login...")
Hello,
I performed this procedure but flutter continues to print as content-type headers only: application/json; charset = utf-8 and not all data present in the console. How can I solve it?
Thanks in advance
I'm still not able to see the cookie in chrome tab
I solved this problem.
BaseOptions options = new BaseOptions( baseUrl: _baseUrl, connectTimeout: 10000, receiveTimeout: 5000, headers: { "Accept": "application/json", }, ); DioForBrowser _d = DioForBrowser(options); var adapter = BrowserHttpClientAdapter(); // This property will automatically set cookies adapter.withCredentials = true; _d.httpClientAdapter = adapter; _d.get("http://localhost:1234/login...")Hello,
I performed this procedure but flutter continues to print as content-type headers only:
application/json; charset = utf-8and not all data present in the console. How can I solve it?Thanks in advance
I'm facing the same issue. I set the withCredentials to true, but I'm still not able to see the cookies in the chrome dev tab.
Most helpful comment
Hello,
I performed this procedure but flutter continues to print as content-type headers only:
application/json; charset = utf-8and not all data present in the console. How can I solve it?Thanks in advance