【问题标题】:Adding Acces-Control-Allow-Origin to app.yml将 Access-Control-Allow-Origin 添加到 app.yaml
【发布时间】:2016-09-05 20:07:04
【问题描述】:

我正在遵循 Google App Engine 文档中的这些说明:

https://cloud.google.com/appengine/docs/python/config/appref

如果您搜索 CORS,您会看到我试图复制的示例。

我的 app.yaml 文件如下所示:

runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /.*
  script: main.app
  http_headers: Access-Control-Allow-Origin: *

libraries:
- name: ssl
  version: latest

但是当我去更新它时,我得到了这个错误:

appcfg.py: error: Error parsing ./app.yaml: Unable to assign value 'Access-Control-Allow-Origin' to attribute 'http_headers':
Value 'Access-Control-Allow-Origin' for http_headers is not of the expected type HttpHeadersDict

为什么会出现此错误?我在做什么与文档不同?

【问题讨论】:

    标签: python google-app-engine cors


    【解决方案1】:

    很遗憾,yaml 无效。

    您遇到了缩进问题。您还必须引用*。应该是:

    handlers:
    - url: /.*
      script: main.app
      http_headers: 
        Access-Control-Allow-Origin: "*"
    

    【讨论】:

      猜你喜欢
      • 2016-06-10
      • 2014-08-14
      • 2017-12-12
      • 2020-01-01
      • 2012-09-19
      • 2013-01-07
      • 2011-06-27
      • 2016-07-03
      相关资源
      最近更新 更多