javascript - Google App Engine CORS“解析 ./app.yaml 时出错:未知 url 处理程序类型”
问题描述
我正在尝试将 CORS 应用于我的一个应用程序引擎,但遇到错误。我已经尝试查看其他答案(间距)的建议,但它仍然错误:
应用程序.yaml
runtime: nodejs10
env_variables:
NODE_ENV: production
CLOUD_SQL_CONNECTION_NAME: domain-name-server:australia-southeast1:db_name
handlers:
- url: /.*
http_headers:
Access-Control-Allow-Origin: https://domain_name-fixed.appspot.com/
错误
ERROR: (gcloud.app.deploy) An error occurred while parsing file: [/home/project/domain_name-server/app.yaml]
Unknown url handler type.
<URLMap
secure=default
static_files=None
application_readable=None
auth_fail_action=redirect
require_matching_file=None
static_dir=None
redirect_http_response_code=None
http_headers={u'Access-Control-Allow-Origin': 'https://domain_name-fixed.appspot.com/'}
url=/.*
script=None
upload=None
api_endpoint=None
expiration=None
position=None
login=optional
mime_type=None
>
in "/home/project/domain_name-server/app.yaml", line 10, column 73
nodejs cors设置
let cors = require("cors")
let origin =
[
"http://localhost:8080",
`http://${ip.address()}:8080`,
"http://localhost:4000",
`http://${ip.address()}:4000`,
"https://domain_name-fixed.appspot.com/"
]
app.use(cors({
origin,
credentials: true
}))
解决方案
您只能为静态文件设置 HTTP 标头。您需要在 nodejs 代码中执行 CORS 部分。
推荐阅读
- javascript - Express JS:- 等待 50 秒的 Firestore 查询响应的条件,否则继续其他进程
- android - Android getDimension 为 textSize 返回错误的值
- python - 计算当前行和最后一行之间具有不同值的天数
- javascript - 样式不适用于 React Native 组件
- php - 在 foreach 中为每个数组结果赋值
- sql - 运行 DBMS_COMPARISON.CONVERGE 子程序时出现错误 ORA-00942
- angular - 验证角度中的特殊字符
- node.js - Node Google Calendar API 快速入门重定向网址
- amazon-web-services - 如何使用 Pulumi 导入现有的 S3 对象?
- angular - Uppercse 的角度变化输入