AWS API Gateway Stages
Understanding Stages
Stages allow you to create multiple versions of the API so that you can experiment with changes to your endpoints, or use different lambda functions depending on your API stage. You can accomplish this using environment variables that can be changed for each stage, much like environment variables in node.
Troubleshooting Stages
If you are receiving a CORS or "403 Forbidden" error while trying ping a secondary stage of your api like "dev" or "staging" (whatever you have called it) you might be running into a similar issue to what I had.
It turns out that stages cannot be accessed using a custom domain. For example if you have setup your API to use a custom domain like api.yoursite.com
, and then you create a dev
stage to that api, you will not be able to access it at api.yoursite.com/dev
.
What you have to do is make sure that the default endpoint setting is enabled in Settings > Default Endpoint
and then direct your requests to the default endpoint url for the endpoint EX: https://abc123.execute-api.us-east-1.amazonaws.com/dev
.
This seems to contradict what a lot of the online documentation says, but this solved the issue for me. I could not get stages to function on a custom domain.
Note that after you have updated this setting, it won't take affect until you have deployed one of the stages (even though this is a global setting for all stages...).
Comments
Recent Work
Basalt
basalt.softwareFree desktop AI Chat client, designed for developers and businesses. Unlocks advanced model settings only available in the API. Includes quality of life features like custom syntax highlighting.
BidBear
bidbear.ioBidbear is a report automation tool. It downloads Amazon Seller and Advertising reports, daily, to a private database. It then merges and formats the data into beautiful, on demand, exportable performance reports.