Google App Engine CORS“解析 ./app.yaml 时出错:未知的 url 处理程序类型”

2024-05-25

我正在尝试将 CORS 应用到我的一个应用程序引擎,但遇到错误。我尝试查看其他答案(间距)的建议,但仍然错误:

app.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/

Errors

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部分。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Google App Engine CORS“解析 ./app.yaml 时出错:未知的 url 处理程序类型” 的相关文章

随机推荐