GoogleCloudPlatform / functions-framework-dart

FaaS (Function as a service) framework for writing portable Dart functions
https://pub.dev/packages/functions_framework
Apache License 2.0
535 stars 54 forks source link

XMLHttpRequest Error when running with Flutter Web #201

Open MisterJimson opened 3 years ago

MisterJimson commented 3 years ago

I've setup this project https://github.com/subfuzion/dart-flutter-fullstack-demo

Works great with macOS desktop, running the backend locally and on Google Cloud Run.

When I try with Flutter Web, both local and on Google Cloud I get error when making the request.

Google Cloud Client error: XMLHttpRequest error

Local Client error: XMLHttpRequest error Backend error:

2021-03-30T09:27:16.234904  0:00:00.003117 OPTIONS [400] /
[BAD REQUEST] OPTIONS   /
Content-Type header is required. (400)
dart:isolate  _RawReceivePortImpl._handleMessage

Flutter Doctor

[✓] Flutter (Channel beta, 2.1.0-12.2.pre, on Mac OS X 10.15.7 19H524 darwin-x64, locale en-CA)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2020.3.3)
[✓] VS Code (version 1.54.3)
[✓] Connected device (4 available)
MisterJimson commented 3 years ago

@subfuzion here is the related issue on this repo FYI

jomiplaz commented 3 years ago

Same problem

jpeiffer commented 2 years ago

I had this same problem and traced it back to CORS which the repo did not previously support. The CORS issue is documented in https://github.com/GoogleCloudPlatform/functions-framework-dart/issues/201, and I am patiently awaiting on feedback for a fix via: https://github.com/GoogleCloudPlatform/functions-framework-dart/pull/317.