dio icon indicating copy to clipboard operation
dio copied to clipboard

Flutter Web

Open MshariAlsayari opened this issue 2 years ago • 2 comments

New Issue Checklist

  • [ ] I have searched for a similar issue in the project and found none

Issue Info

Info Value
Platform Name e.g. flutter / ios / android
Platform Version e.g. 1.5.0 / 12.0 / 9.0
Dio Version e.g. 2.1.0 / 1.0.17
Android Studio / Xcode Version e.g. Android Studio 3.3.2 / Xcode 10.2.1
Repro rate e.g. all the time (100%) / sometimes x% / only once
Repro with our demo prj e.g. does it happen with our demo project?
Demo project link e.g. link to a demo project that highlights the issue

Issue Description and Steps

Please fill in the detailed description of the issue (full output of any stack trace, compiler error, ...) and the steps to reproduce the issue.

Platform Name : Flutter Web Platform Version Flutter 2.13.0-0.0.pre.747 • channel master Dio Version : ^4.0.6 Android Studio: 4.1.1 Repro rate : 100%

Hi, I am using Dio lib but I am facing an issue when I want to use it with Flutter Web. I can't do any request.

Dio implementation

Screen Shot 2022-04-28 at 11 23 58 PM

Screen Shot 2022-04-28 at 11 24 29 PM

Screen Shot 2022-04-28 at 11 25 10 PM

My Server log

Screen Shot 2022-04-28 at 11 26 33 PM

MshariAlsayari avatar Apr 28 '22 20:04 MshariAlsayari

FYI if I do the request from Android mobile is working fine but from a browser not

MshariAlsayari avatar Apr 28 '22 20:04 MshariAlsayari

Does your web server provide the correct headers for CORS? If you're requesting from localhost, it may fail as the OPTIONS request fails. That's also probably why your webserver fails too, 'cause of the OPTIONS request done in pre-flight.

Perhaps your issue is due to CORS taking place, which doesn't really happen on Android 'cause it's a native call there instead of the XHR your browser performs...

Open DevTools and have a look at the request it performs, then fix stuff accordingly. Handle the OPTIONS call first, then see what's going on with CORS.

anatolinicolae avatar May 03 '22 08:05 anatolinicolae