-
Notifications
You must be signed in to change notification settings - Fork 104
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
CORS Issue #545
Comments
I published a video for a simple Lambda-based way of setting up CORS: https://www.youtube.com/watch?v=typ-AJQGKKI I'll try to spend next week's episode on setting up the mock integration style that doesn't use a Lambda on the OPTIONS method. |
Would be great if you could give a hint. I'm sort of blocked right now. Using a lambda seems to be an overkill for this. |
Using |
Take a look at https://www.pulumi.com/docs/reference/pkg/aws/apigateway/integrationresponse/ -- you'll want to setup a mock integration response that returns the appropriate headers |
In particular, when setting it up, you'll want https://www.pulumi.com/docs/reference/pkg/aws/apigateway/methodresponse/ to correctly return the CORS headers https://www.pulumi.com/docs/reference/pkg/aws/apigateway/methodresponse/#responseparameters_nodejs and similarly on the https://www.pulumi.com/docs/reference/pkg/aws/apigateway/integrationresponse/ to set those headers appropriately |
Okay, can I use these with the |
Yes, these should hang off the RestApi exposed by |
That does it for me. Thanks a lot @leezen! |
For anyone looking for a solution, here is what I did as hinted by @leezen.
|
Thanks for your solution @allroundexperts . I was able to apply the methods to my existing API endpoints. One problem though - if i have catch all endpoints like /{proxy+}, the OPTIONS appears to be overriden. The catch all endpoints is created by the cross walk module automatically as shown in this issue. |
I added this to my API routes to solve the issue.
|
In addition to what @oscarmeanwell mentioned, ensure that your endpoint also returns the same access control headers otherwise it won't work. For example like this:
|
Followed the advice of both @leezen #545 (comment) and @allroundexperts #545 (comment). So many thanks 🙏, I consider myself more a sys-admin and am not nearly as competent a dev as @allroundexperts so structured mine slightly differently. Apologies in advance for any mistakes. Happy to respond to any queries. Rest APICreate the rest api using
Config to configure CORSI chose to define a class to create the MOCK endpoint that returns CORS headers. Credit to @allroundexperts
Note that i.e.
Use the CORS class to handle CORS on the rest APINow as @leezen suggested. Hang the MOCK endpoint off the resources created in the above rest api.
You should now end with Resources in your api that look like below. Similar to something created with SAM |
I wonder if anyone could point me in any direction to get this working in yaml. |
Good luck with that. I found myself here because Pulumi didn't have much in the way of working examples in their main language TypeScript. Please post if you find anything. |
After spending two days on it I gave up and am going to implement the api gateway manually with the apigatewayv2 provider instead of trying to use Crosswalk (awsx). Something like this https://www.pulumi.com/ai/conversations/a8a10d57-8764-4586-9bdb-3ba2db15fbcd?prompt=Create+an+aws-apigateway.RestAPI+resource |
How can I achieve that?
It seems that the
target
requiresuri
as a required parameter. However, for mock integrations, I can't see any value for that parameter. I also could not find anything on how to setup header mappings for the mock request. Another issue that I am facing is that there is no way to specify multiple methods on a single path (eg POST and OPTIONS for /pet path).Your help will be greatly appreciated!
Thanks
The text was updated successfully, but these errors were encountered: