Enable CORS in GO application in App engine

Asked

Viewed 24 times

0

My API does not respond to requests from third-party websites and for that I need to enable CORS, I tried to add the Access-Control-Allow-Origin: "*" in the app.yaml but I get the following error.

ERROR: (gcloud.app.deploy) An error occurred while Parsing file: [/Users/Rafa/go/src/github.com/quickcep/api/app.yaml] Unexpected attribute "http_headers" for Mapping type script. in "/path/api/app.yaml", line 7, column 37

The contents of the file app.yaml is:

runtime: go
api_version: go1.9
handlers:
- url: /.*
    script: _go_app
    http_headers:
        Access-Control-Allow-Origin: "*"

1 answer

0

There is a problem in the identation of the yaml file, it should be like this:

runtime: go
api_version: go1.9
handlers:
- url: /.*
  script: _go_app
  http_headers: 
    Access-Control-Allow-Origin: "*"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.