Last active
October 20, 2020 22:46
-
-
Save gillisandrew/7659ca4466627921169cc3ccdb053c27 to your computer and use it in GitHub Desktop.
Short request integration for AWS API Gateway mock integration. For use on the OPTIONS method to support CORS.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #set($origin = $input.params().get('header').get('Origin')) | |
| { | |
| ## TODO: update regex to match your supported API origins | |
| #if($origin.matches("https?:example.com")) | |
| "statusCode": 204 | |
| #set($context.responseOverride.header.Access-Control-Allow-Origin = $origin) | |
| #set($context.responseOverride.header.Access-Control-Allow-Methods = "OPTIONS,GET,PUT,POST,DELETE,PATCH,HEAD") | |
| #set($context.responseOverride.header.Access-Control-Allow-Headers = "Authorization,Content-Type,Accept") | |
| #set($context.responseOverride.header.Access-Control-Max-Age = "86400") | |
| #else | |
| "statusCode": 401 | |
| #end | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment