Set arbitrary headers for APIG (will enable CORS)
See original GitHub issueCurrently 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:
- Created 7 years ago
- Reactions:5
- Comments:18 (7 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
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.