I am encountering a CORS error when trying to view the Firebase Emulator UI through the browser. However, the emulator is accessible from a Flutter app, only the browser access is blocked by CORS policy.
'Access to XMLHttpRequest at 'https://4000-idx-xxxxxxx-1722318992255.cluster-qpa6grkipzc64wfjrbr3hsdma2.cloudworkstations.dev' from origin 'http://localhost:4000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
The Firebase Emulator is accessible from a Flutter app but not through a browser due to CORS policy. Is there any workaround or solution to configure CORS settings for Firebase Emulator in this environment?
Is there an existing issue for this?
Which plugins are affected?
Core
Which platforms are affected?
Web
Description
I am using the Project IDX online IDE to run the Firebase Emulator and accessing the link provided by Project IDX on port 4000:
https://4000-idx-xxxxxxxxx-1722318992255.cluster-qpa6grkipzc64wfjrbr3hsdma2.cloudworkstations.dev/
I am encountering a CORS error when trying to view the Firebase Emulator UI through the browser. However, the emulator is accessible from a Flutter app, only the browser access is blocked by CORS policy.
Error Message:
https://4000-idx-xxxxxxx-1722318992255.cluster-qpa6grkipzc64wfjrbr3hsdma2.cloudworkstations.dev' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Reproducing the issue
Use Project IDX online IDE to run Firebase Emulator. Access the link provided by Project IDX on port 4000 through a browser: https://4000-idx-xxxxxxxxx-1722318992255.cluster-qpa6grkipzc64wfjrbr3hsdma2.cloudworkstations.dev/ Observe the CORS error in the browser console.
Firebase Core version
node@377e77b1b504:~$ firebase --version 13.14.2 node@377e77b1b504:~$
Flutter Version
3.22.2
Relevant Log Output
Flutter dependencies
Expand
Flutter dependencies
snippet```yaml xxxxxx-7371638:~/xxxxxxx{main}$ flutter pub deps -- --style=compact Dart SDK 3.4.3 Flutter SDK 3.22.2 xxxxxxxx 0.0.2+1 dependencies: - back_button_interceptor 7.0.3 [collection flutter] - cached_network_image 3.3.1 [cached_network_image_platform_interface cached_network_image_web flutter flutter_cache_manager octo_image] - clipboard 0.1.3 [flutter] - cloud_firestore 4.15.9 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta] - equatable 2.0.5 [collection meta] - file_picker 6.2.0 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface ffi path win32] - firebase_analytics 10.8.10 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter] - firebase_auth 4.17.9 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 2.27.1 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_storage 11.6.10 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter] - firebase_ui_auth 1.13.1 [email_validator firebase_auth firebase_core firebase_dynamic_links firebase_ui_localizations firebase_ui_oauth firebase_ui_shared flutter flutter_localizations meta] - firebase_ui_oauth_google 1.3.1 [firebase_auth firebase_ui_oauth flutter google_sign_in] - flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine] - flutter_bloc 8.1.5 [bloc flutter provider] - flutter_line_sdk 2.3.6 [flutter] - flutter_udid 3.0.0 [flutter crypto] - go_router 13.2.4 [collection flutter flutter_web_plugins logging meta] - google_mobile_ads 4.0.0 [meta flutter webview_flutter_android webview_flutter_wkwebview webview_flutter] - http 1.2.1 [async http_parser meta web] - image 4.1.7 [archive meta xml] - infinite_scroll_pagination 4.0.0 [flutter flutter_staggered_grid_view sliver_tools] - intl 0.19.0 [clock meta path] - jwt_decoder 2.0.1 - like_button 2.0.5 [flutter] - logger 2.1.0 - modal_bottom_sheet 3.0.0 [flutter] - path_provider 2.1.2 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows] - pigeon 17.1.2 [analyzer args collection meta path yaml] - readmore 3.0.0 [flutter] - shared_preferences 2.2.2 [flutter shared_preferences_android shared_preferences_foundation shared_preferences_linux shared_preferences_platform_interface shared_preferences_web shared_preferences_windows] - sign_in_with_apple 6.0.0 [flutter meta sign_in_with_apple_platform_interface sign_in_with_apple_web] - universal_html 2.2.4 [async csslib charcode collection html meta source_span typed_data universal_io] - url_launcher 6.2.5 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] - uuid 4.3.3 [crypto sprintf meta fixnum] - video_player 2.8.3 [flutter html video_player_android video_player_avfoundation video_player_platform_interface video_player_web] dev dependencies: - fake_cloud_firestore 2.4.8 [flutter cloud_firestore cloud_firestore_platform_interface collection plugin_platform_interface quiver rxdart mock_exceptions fake_firebase_security_rules rx equatable clock] - flutter_lints 3.0.1 [lints] - flutter_test 0.0.0 [flutter test_api matcher path fake_async clock stack_trace vector_math leak_tracker_flutter_testing async boolean_selector characters collection leak_tracker leak_tracker_testing material_color_utilities meta source_span stream_channel string_scanner term_glyph vm_service] - test 1.25.2 [analyzer async boolean_selector collection coverage http_multi_server io js matcher node_preamble package_config path pool shelf shelf_packages_handler shelf_static shelf_web_socket source_span stack_trace stream_channel test_api test_core typed_data web_socket_channel webkit_inspection_protocol yaml] transitive dependencies: - _fe_analyzer_shared 67.0.0 [meta] - _flutterfire_internals 1.3.26 [collection firebase_core firebase_core_platform_interface flutter meta] - analyzer 6.4.1 [_fe_analyzer_shared collection convert crypto glob meta package_config path pub_semver source_span watcher yaml] - antlr4 4.13.1 [logging collection] - archive 3.4.10 [crypto path pointycastle] - args 2.4.2 - async 2.11.0 [collection meta] - bloc 8.1.4 [meta] - boolean_selector 2.1.1 [source_span string_scanner] - cached_network_image_platform_interface 4.0.0 [flutter flutter_cache_manager] - cached_network_image_web 1.1.1 [cached_network_image_platform_interface flutter flutter_cache_manager] - cel 0.5.3 [antlr4 collection equatable] - characters 1.3.0 - charcode 1.3.1 - clock 1.1.1 - cloud_firestore_platform_interface 6.1.10 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 3.10.9 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js] - collection 1.18.0 - convert 3.1.1 [typed_data] - coverage 1.7.2 [args logging package_config path source_maps stack_trace vm_service] - crypto 3.0.3 [typed_data] - csslib 1.0.0 [source_span] - desktop_webview_auth 0.0.15 [crypto flutter http flutter_web_plugins plugin_platform_interface] - email_validator 2.1.17 - fake_async 1.3.1 [clock collection] - fake_firebase_security_rules 0.5.3 [antlr4 cel equatable logger tuple] - ffi 2.1.2 - file 7.0.0 [meta path] - firebase_analytics_platform_interface 3.9.10 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_analytics_web 0.5.5+22 [_flutterfire_internals firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - firebase_auth_platform_interface 7.1.9 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 5.10.0 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser js meta web] - firebase_core_platform_interface 5.0.0 [collection flutter flutter_test meta plugin_platform_interface] - firebase_core_web 2.12.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta web] - firebase_dynamic_links 5.4.18 [firebase_core firebase_core_platform_interface firebase_dynamic_links_platform_interface flutter meta plugin_platform_interface] - firebase_dynamic_links_platform_interface 0.2.6+26 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_storage_platform_interface 5.1.13 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_storage_web 3.8.0 [_flutterfire_internals async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta web] - firebase_ui_localizations 1.10.2 [flutter flutter_localizations path] - firebase_ui_oauth 1.5.1 [desktop_webview_auth firebase_auth firebase_ui_auth firebase_ui_shared flutter_svg flutter] - firebase_ui_shared 1.4.1 [flutter] - fixnum 1.1.0 - flutter_cache_manager 3.3.1 [clock collection file flutter http path path_provider rxdart sqflite uuid] - flutter_localizations 0.0.0 [flutter intl characters clock collection material_color_utilities meta path vector_math] - flutter_plugin_android_lifecycle 2.0.17 [flutter] - flutter_staggered_grid_view 0.7.0 [flutter] - flutter_svg 2.0.10+1 [flutter http vector_graphics vector_graphics_codec vector_graphics_compiler] - flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math] - frontend_server_client 3.2.0 [async path] - glob 2.1.2 [async collection file path string_scanner] - google_identity_services_web 0.3.1+1 [meta web] - google_sign_in 6.2.1 [flutter google_sign_in_android google_sign_in_ios google_sign_in_platform_interface google_sign_in_web] - google_sign_in_android 6.1.21 [flutter google_sign_in_platform_interface] - google_sign_in_ios 5.7.4 [flutter google_sign_in_platform_interface] - google_sign_in_platform_interface 2.4.5 [flutter plugin_platform_interface] - google_sign_in_web 0.12.4 [flutter flutter_web_plugins google_identity_services_web google_sign_in_platform_interface http web] - html 0.15.4 [csslib source_span] - http_multi_server 3.2.1 [async] - http_parser 4.0.2 [collection source_span string_scanner typed_data] - io 1.0.4 [meta path string_scanner] - js 0.6.7 [meta] - leak_tracker 10.0.4 [clock collection meta path vm_service] - leak_tracker_flutter_testing 3.0.3 [flutter leak_tracker leak_tracker_testing matcher meta] - leak_tracker_testing 3.0.1 [leak_tracker matcher meta] - lints 3.0.0 - logging 1.2.0 - matcher 0.12.16+1 [async meta stack_trace term_glyph test_api] - material_color_utilities 0.8.0 [collection] - meta 1.12.0 - mime 1.0.5 - mock_exceptions 0.8.2 [matcher] - more 4.2.0 [characters clock collection meta] - nested 1.0.0 [flutter] - node_preamble 2.0.2 - octo_image 2.0.0 [flutter] - package_config 2.1.0 [path] - path 1.9.0 - path_parsing 1.0.1 [vector_math meta] - path_provider_android 2.2.2 [flutter path_provider_platform_interface] - path_provider_foundation 2.3.2 [flutter path_provider_platform_interface] - path_provider_linux 2.2.1 [ffi flutter path path_provider_platform_interface xdg_directories] - path_provider_platform_interface 2.1.2 [flutter platform plugin_platform_interface] - path_provider_windows 2.2.1 [ffi flutter path path_provider_platform_interface win32] - petitparser 6.0.2 [meta] - platform 3.1.4 - plugin_platform_interface 2.1.8 [meta] - pointycastle 3.7.4 [collection convert js] - pool 1.5.1 [async stack_trace] - provider 6.1.2 [collection flutter nested] - pub_semver 2.1.4 [collection meta] - quiver 3.2.1 [matcher] - rx 0.3.0 [collection matcher meta more] - rxdart 0.27.7 - shared_preferences_android 2.2.1 [flutter shared_preferences_platform_interface] - shared_preferences_foundation 2.3.5 [flutter shared_preferences_platform_interface] - shared_preferences_linux 2.3.2 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface] - shared_preferences_platform_interface 2.3.2 [flutter plugin_platform_interface] - shared_preferences_web 2.3.0 [flutter flutter_web_plugins shared_preferences_platform_interface web] - shared_preferences_windows 2.3.2 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface] - shelf 1.4.1 [async collection http_parser path stack_trace stream_channel] - shelf_packages_handler 3.0.2 [path shelf shelf_static] - shelf_static 1.1.2 [convert http_parser mime path shelf] - shelf_web_socket 1.0.4 [shelf stream_channel web_socket_channel] - sign_in_with_apple_platform_interface 1.0.0 [flutter plugin_platform_interface meta] - sign_in_with_apple_web 2.0.0 [flutter flutter_web_plugins sign_in_with_apple_platform_interface] - sky_engine 0.0.99 - sliver_tools 0.2.12 [flutter] - source_map_stack_trace 2.1.1 [path source_maps stack_trace] - source_maps 0.10.12 [source_span] - source_span 1.10.0 [collection path term_glyph] - sprintf 7.0.0 - sqflite 2.3.2 [flutter sqflite_common path] - sqflite_common 2.5.3 [synchronized path meta] - stack_trace 1.11.1 [path] - stream_channel 2.1.2 [async] - string_scanner 1.2.0 [source_span] - synchronized 3.1.0+1 - term_glyph 1.2.1 - test_api 0.7.0 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph] - test_core 0.6.0 [analyzer args async boolean_selector collection coverage frontend_server_client glob io meta package_config path pool source_map_stack_trace source_maps source_span stack_trace stream_channel test_api vm_service yaml] - tuple 2.0.2 - typed_data 1.3.2 [collection] - universal_io 2.2.2 [collection meta typed_data] - url_launcher_android 6.3.0 [flutter url_launcher_platform_interface] - url_launcher_ios 6.2.5 [flutter url_launcher_platform_interface] - url_launcher_linux 3.1.1 [flutter url_launcher_platform_interface] - url_launcher_macos 3.1.0 [flutter url_launcher_platform_interface] - url_launcher_platform_interface 2.3.2 [flutter plugin_platform_interface] - url_launcher_web 2.3.0 [flutter flutter_web_plugins url_launcher_platform_interface web] - url_launcher_windows 3.1.1 [flutter url_launcher_platform_interface] - vector_graphics 1.1.11+1 [flutter http vector_graphics_codec] - vector_graphics_codec 1.1.11+1 - vector_graphics_compiler 1.1.11+1 [args meta path_parsing xml vector_graphics_codec path] - vector_math 2.1.4 - video_player_android 2.4.12 [flutter video_player_platform_interface] - video_player_avfoundation 2.5.6 [flutter video_player_platform_interface] - video_player_platform_interface 6.2.2 [flutter plugin_platform_interface] - video_player_web 2.3.0 [flutter flutter_web_plugins video_player_platform_interface web] - vm_service 14.2.1 - watcher 1.1.0 [async path] - web 0.5.1 - web_socket_channel 2.4.4 [async crypto stream_channel web] - webkit_inspection_protocol 1.2.1 [logging] - webview_flutter 4.7.0 [flutter webview_flutter_android webview_flutter_platform_interface webview_flutter_wkwebview] - webview_flutter_android 3.16.0 [flutter webview_flutter_platform_interface] - webview_flutter_platform_interface 2.10.0 [flutter meta plugin_platform_interface] - webview_flutter_wkwebview 3.13.0 [flutter path webview_flutter_platform_interface] - win32 5.3.0 [ffi] - xdg_directories 1.0.4 [meta path] - xml 6.5.0 [collection meta petitparser] - yaml 3.1.2 [collection source_span string_scanner] xxxxxxxx-7371638:~/xxxxxxxxx{main}$ ```
Additional context and comments
The Firebase Emulator is accessible from a Flutter app but not through a browser due to CORS policy. Is there any workaround or solution to configure CORS settings for Firebase Emulator in this environment?