GAE(python):设置Access-Control-Allow-Origin

时间:2022-08-19 23:13:35

I have a static page in google app engine(python), and I want to $.load() the content of this page from another page -> therefore I have a CORS problem. How can I set in GAE to allow all domains to load the content of the page?(Access-Control-Allow-Origin: *)

我在谷歌应用程序引擎(python)中有一个静态页面,我想从另一个页面加载这个页面的内容——>,因此我有一个CORS问题。如何在GAE中设置允许所有域加载页面内容?(Access-Control-Allow-Origin:*)

2 个解决方案

#1


6  

In app.yaml

在app.yaml

http_headers:
  X-Foo-Header: foo
  X-Bar-Header: bar value

https://developers.google.com/appengine/docs/python/config/appconfig#Static_Directory_Handlers

https://developers.google.com/appengine/docs/python/config/appconfig Static_Directory_Handlers

#2


5  

Assuming you're using webapp (you haven't specified), put this anywhere in your handler:

假设你正在使用webapp(你还没有指定),把这个放在你的处理器的任何地方:

self.response.headers['Access-Control-Allow-Origin'] = '*'

#1


6  

In app.yaml

在app.yaml

http_headers:
  X-Foo-Header: foo
  X-Bar-Header: bar value

https://developers.google.com/appengine/docs/python/config/appconfig#Static_Directory_Handlers

https://developers.google.com/appengine/docs/python/config/appconfig Static_Directory_Handlers

#2


5  

Assuming you're using webapp (you haven't specified), put this anywhere in your handler:

假设你正在使用webapp(你还没有指定),把这个放在你的处理器的任何地方:

self.response.headers['Access-Control-Allow-Origin'] = '*'