question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Set arbitrary headers for APIG (will enable CORS)

See original GitHub issue

Currently I can define a resource like this:

@app.route('/scalars', methods=['GET', 'OPTIONS']) def scalars(): return { 'mau': 27048, 'wau: 7003 }'

The OPTIONS will help me with enabling CORS in APIG But I’m still missing the ‘Access-Control-Allow-Origin’ header, so I enable it manually in the console after each deploy.

One approach would be to configure headers in the method. Another would be to call the “Enable CORS” magic button in APIG.

WDYT?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:18 (7 by maintainers)

github_iconTop GitHub Comments

6reactions
dmultercommented, Jan 5, 2018

The CORS support is nice, but I see that the cors=True wasn’t made part of Chalice instantiation. I have lots of routes and it would be nicer if I could just turn it on for everything. Not sure what others think.

3reactions
chrisgilmerprojcommented, Sep 22, 2016

I like the above. One thing that I’d want is to ensure that the CORS headers are on all the response codes, not just 200. Otherwise I’ll still have to go in and update 400, 403, 404, etc.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Set arbitrary headers for APIG (will enable CORS) · Issue #70
The OPTIONS will help me with enabling CORS in APIG But I'm still missing the 'Access-Control-Allow-Origin' header, so I enable it manually in...
Read more >
Enabling CORS for a REST API resource
Learn what cross-origin resource sharing (CORS) is, whether you want to enable it, and how to enable CORS methods in API Gateway.
Read more >
API Gateway - CORS
Access-Control-Expose-Headers: This is the response header fields that can be viewed during cross-region access. Access-Control-Allow-Methods: ...
Read more >
AWS API Gateway - CORS + POST not working
You have to set the Header 'Access-Control-Allow-Origin' from your Lambda code itself. Its mentioned in the doc. Python code sample: response = ...
Read more >
Enabling Cross-Origin Requests in ASP.NET Web API 2
How CORS Works · The request method is GET, HEAD, or POST, and · The application does not set any request headers other...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found