fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.
https://fzyzcjy.github.io/flutter_rust_bridge/
MIT License
4.29k stars 301 forks source link

Rust Initialization Failure in Release Mode with Missing Cross-Origin Headers #2354

Closed DevAdalat closed 1 month ago

DevAdalat commented 1 month ago

Describe the bug

First, thank you for this great package and all the hard work behind it!

When running my Flutter web app using python3 -m http.server after flutter build, I encounter the following error during the initialization of Rust in release mode:

Failed to initialize RustLib Buffers cannot be shared due to missing cross-origin headers. Please refer to https://fzyzcjy.github.io/flutter_rust_bridge/manual/miscellaneous

However, it works in debug mode, where I am passing the --web-header argument. How can I run it in release mode?

I used this command to build and run application: flutter_rust_bridge_codegen create webtest flutter_rust_bridge_codegen build-web --release flutter build web cd build/web && python3 -m http.serve

If this is not a bug, could you please guide me on how to fix this or how to run it in release mode?

Steps to reproduce

Hint: A simple way to reproduce is to clone and modify the https://github.com/fzyzcjy/flutter_rust_bridge/tree/master/frb_example/dart_minimal example package according to your needs.

  1. ...
  2. ...
  3. ...

Logs

Logs

Expected behavior

RustLib should initialize successfully without cross-origin header issues in release mode

Generated binding code

No response

OS

Ubuntu 22.04

Version of flutter_rust_bridge_codegen

2.5.0

Flutter info

No response

Version of clang++

No response

Additional context

No response

welcome[bot] commented 1 month ago

Hi! Thanks for opening your first issue here! :smile:

fzyzcjy commented 1 month ago

Hi, you are welcome!

Doc: https://cjycode.com/flutter_rust_bridge/manual/miscellaneous/web-cross-origin

You can search how to add the headers in http.serve

DevAdalat commented 1 month ago

I wanted to update you that I have resolved the issue. I used the static-web-server with some custom configuration, and now everything is working in release mode.

I will be closing this issue.

Thanks for your support!

fzyzcjy commented 1 month ago

You are welcome!

github-actions[bot] commented 2 weeks ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.