When using the "amplify update api" command, Kevin Le mentioned that you can easily add new root paths like "/items" or "/customers". However, I have encountered difficulties when trying to add nested paths such as "/customer/addAddress" after creating the initial API.
Here are some things I have attempted:
- I can include nested paths during the initial API setup, but not when updating it later on
- I tried modifying the cloud formation template to incorporate the nested paths in the API gateway, but any requests to these paths were intercepted by the root path's proxy
- Adding the nested paths directly in the express lambda function seemed like a workaround, but it goes against the purpose of utilizing API Gateway
In order to truly leverage the power of API Gateway and make the most out of Amplify's REST API capabilities, there is a need for enhancements. It would be beneficial to have the ability to separate functions for different HTTP methods like GET, POST, PUT, etc.
UPDATE: After further investigation, I discovered a solution to this issue. By removing the {proxy} endpoint associated with the "root" path in the cloud formation file for the API gateway, located at: "project root"/amplify/backend/api/"api name"/"api name"-cloudformation-template.json, the issue was resolved. Simply delete the path found under Resources->"api name"->Properties->Body->paths->"api name"/{proxy+}.
FURTHER INVESTIGATION: Although I have yet to test this, it is possible that the order of paths listed in the cloud formation file could impact how requests are processed. By reorganizing the paths so that the "root" proxy is placed last, it may eliminate the need to remove it altogether. Special thanks to Piotr for helping me correct my grammar!