-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(feat) Cors Support #1242
(feat) Cors Support #1242
Conversation
… feature/cors_support Add cors support using aws#1009 as a ref
@viksrivat Can you handle the merge conflicts here? I will do a quick pass over once you do that. |
ApiGateway::RestApi only supports within methods section. This requires parsing the requestParameters section of the ApiGateway resource. Since we currently don'd do this, the best functionality is to ignore cors in RestApi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of this will need to be changed based on other prs you have in process. Once the stage pr is merged, you should rebase here and handle the comments. Overall, this looks good and would love to get this into a release soon, as this will be a great addition for customers.
if cors_prop and isinstance(cors_prop, dict): | ||
allow_methods = cors_prop.get("AllowMethods", ','.join(Route.ANY_HTTP_METHODS)) | ||
|
||
if allow_methods and "OPTIONS" not in allow_methods and "options" not in allow_methods: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to normalize allow_methods
here, just comparing OPTIONS and options is not enough, unless SAM or API gateway only allow these two ways for the strings.
|
||
try: | ||
event = self._construct_event(request, self.port, self.api.binary_media_types, self.api.stage_name, | ||
self.api.stage_variables) | ||
self.api.stage_variables, cors_headers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this right? Cors_headers always get added to the event?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I believe CORS needs to be added to every request.
Is this branch ready to merge to candidate 20 branch? I see there are new commits added after the approval. |
The only changes that I added were updating some of the integration tests for Travis CI to pass. |
Updated this to track and merge into develop. |
@viksrivat Can you fix the flake8 errors: Running |
Issue #, if available:
Description of changes:
Adds Cors support to ApiGateway. This completes the #1009 pr
Checklist:
make pr
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.