将Acces-Control-Allow-Origin添加到app.yml [英] Adding Acces-Control-Allow-Origin to app.yml
本文介绍了将Acces-Control-Allow-Origin添加到app.yml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在遵循Google App Engine文档中的以下说明:
I'm following these instructions from Google App Engine docs :
https://cloud.google.com/appengine/docs/python/config/appref
如果您搜索CORS时,会看到我要复制的示例。
If you search for CORS, you'll see the example I am trying to copy.
我的app.yaml文件如下:
My app.yaml file looks like:
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: main.app
http_headers: Access-Control-Allow-Origin: *
libraries:
- name: ssl
version: latest
但是当我进行更新时,会出现此错误:
However when I go to update it I get this error:
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
为什么会出现此错误?我在做什么与文档不同?
Why am I getting this error? What am I doing differently than the docs?
推荐答案
不幸的是,这无效 yaml 。
您有缩进问题。另外,您必须引用 *
。应该是:
You have an indentation problem. Also you have to quote the *
. Should be:
handlers:
- url: /.*
script: main.app
http_headers:
Access-Control-Allow-Origin: "*"
这篇关于将Acces-Control-Allow-Origin添加到app.yml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文