Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work for Flutter Web, fails with XMLHttpRequest error #26

Open
oianmol opened this issue Mar 13, 2021 · 6 comments
Open

Doesn't work for Flutter Web, fails with XMLHttpRequest error #26

oianmol opened this issue Mar 13, 2021 · 6 comments

Comments

@oianmol
Copy link

oianmol commented Mar 13, 2021

Stack Trace

` Error: XMLHttpRequest error.
dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 906:28 get current
packages/http/src/browser_client.dart 71:22
dart-sdk/lib/async/zone.dart 1612:54 runUnary
dart-sdk/lib/async/future_impl.dart 152:18 handleValue
dart-sdk/lib/async/future_impl.dart 704:44 handleValueCallback
dart-sdk/lib/async/future_impl.dart 733:13 _propagateToListeners
dart-sdk/lib/async/future_impl.dart 530:7 [_complete]
dart-sdk/lib/async/stream_pipe.dart 61:11 _cancelAndValue
dart-sdk/lib/async/stream.dart 1219:7
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 324:14 _checkAndCall
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 329:39 dcall
dart-sdk/lib/html/dart2js/html_dart2js.dart 37307:58

at Object.createErrorWithStack (http://localhost:53250/dart_sdk.js:5348:12)
at Object._rethrow (http://localhost:53250/dart_sdk.js:39350:16)
at async._AsyncCallbackEntry.new.callback (http://localhost:53250/dart_sdk.js:39344:13)
at Object._microtaskLoop (http://localhost:53250/dart_sdk.js:39176:13)
at _startMicrotaskLoop (http://localhost:53250/dart_sdk.js:39182:13)
at http://localhost:53250/dart_sdk.js:34689:9`

I tried to run the sample code and it fails, Is this a known bug ?

@ziadshebl
Copy link

Same issue happened to me, is there any workaround or solution?

@caseyryan
Copy link

Your backend must have an endpoint that accepts OPTIONS request (it's called a Preflight request) and send response with status code 204 to it. Literally if you request GET https://example.com/users/profile a browser will first try to do it with OPTIONS https://example.com/users/profile and when it gets 204 then it will try GET. Make sure your backend can process it

@oianmol
Copy link
Author

oianmol commented May 25, 2021 via email

@caseyryan
Copy link

caseyryan commented May 25, 2021

Because Flutter mobile is not a browser. Only web browsers send Preflight requests.
Google "preflight request" if you want to know more

@mirrorlink
Copy link

@ollyde
Copy link

ollyde commented Apr 26, 2022

I have the same issue, and we are going across sites to fetch meta data. For example, if someone posts a YouTube link. How can we get around this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants