问题
我在Flutter Web中编写了一个应用程序。当我在浏览器中运行它(调试模式),我收到以下错误:
cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://www.googleapis.com/identityto...
当我以发布模式运行它时,只会得到以下结果:
Error while fetching an original source: NetworkError when attempting to fetch resource.
Source URL: org-dartlang-sdk:///sdk/lib/_internal/js_runtime/lib/js_helper.dart
其他信息
- 该应用程序托管在Firebase Hosting中,但在没有Firebase的情况下也会出现错误
- 我认为问题在于两种情况下的cors,但发布模式只有较少的日志
我尝试过的
根据此文档或此问题, 我需要使用Expressjs添加一些内容:
const express = require('express');
const cors = require('cors');
const app = express();
app.use(cors({ origin: true }));
- 在Dart/Flutter中是否有类似于Expressjs的东西?我看到了这个,但我无法让它工作。
- 或者还有其他设置头信息的方法吗?