How to enable CORS on Python Server Google App Engine?

I see the following error in the Javascript console:

VM31:1 XMLHttpRequest cannot load '<some-url>'. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '<my-url>' is therefore not allowed access.

      

How can I enable resource sharing across sources using Google App Engine (Python)?

+3


source to share


2 answers


You need to use Access-Control-Allow-Origin

http header in yaml config

handlers:
- url: /
  ...
  http_headers:
    Access-Control-Allow-Origin: http://my-url

      



Find under CORS support in the docs

+3


source


For a python script, you can add the following line alongside the other self.response.header lines.

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

      



This worked for me. The idea was taken from the php issue mentioned in the notes of the other answer.

+2


source







All Articles