【发布时间】:2020-06-04 03:29:39
【问题描述】:
问题
我在 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 托管中,但在没有 Firebase 的 localhost 上也会出现错误
- 我认为这两种情况都存在问题,但发布模式的日志较少
我尝试了什么
根据this 文档或this 问题,我必须使用 Expressjs 添加一些内容,例如:
const express = require('express');
const cors = require('cors');
const app = express();
app.use(cors({ origin: true }));
- 在 Dart/Flutter 中有没有类似 Expressjs 的东西?我看到了this,但我无法让它工作。
- 或者有没有其他方法来设置标题?
【问题讨论】:
-
感谢您使用edit 按钮。请避免就同一问题发布多个问题并为他人创造工作。干杯。
标签: firebase dart cors firebase-hosting flutter-web