-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
RestApi: CDK is duplicating methods that added to a proxy by adding them to the root resource #25849
Comments
I guess instead of const proxy = restApi.root.addProxy({
anyMethod: false,
});
proxy.addMethod('OPTIONS'); Maybe you should try this. const proxy = restApi.root.addProxy({
anyMethod: false,
});
restApi.root.addMethod('OPTIONS'); As you are adding an method to the |
Is there any workarounds to this? I'm facing the same issue. |
You can try with
Or you can try adding a resource under the root and add your proxy to that
to add cors Options you could write a function like the one below that uses
Hope this is helpful. |
@alantos Good afternoon. Could you please confirm if this is still an issue or if it could be closed? |
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
Describe the bug
Having RestApi
When you add proxy resource to it like so and then you add a method(example shows OPTIONS but it happens with other methods too) to the created proxy
Cloud formation template that is created has this method created twice, one attached to a proxy and one more attached to the root of the RestApi. That when deployed creates 2 methods instead of 1, as per template.
When you would add some other path resource before proxy i.e.
It would create only one method as expected.
Same issue occurs when you import existing resource i.e.
It could point at root or even further down the path. And if you add proxy directly to it and some method
It is going to duplicate that method also to the root of the restApi.
And again if you add some additional path before adding proxy it will only create one method, as expected.
Expected Behavior
Cloud formation template should only have one method added, to the proxy resource and not to the root of the RestApi.
Current Behavior
Cloud formation template that is created has this method created twice, one attached to a proxy and one more attached to the root of the RestApi.
Reproduction Steps
Added to the description of the bug
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.82.0 (build 3a8648a)
Framework Version
No response
Node.js Version
v14.19.0
OS
macOS 12.6 (M1 Pro)
Language
Typescript
Language Version
Typescript (4.9.5)
Other information
No response
The text was updated successfully, but these errors were encountered: