AWS API Gateway - Remove Stage Name From URI

You can do this with API Gateway Custom Domains. This allows you to optionally omit the stage name in the custom domain name mapping.


I was unable to use the custom domains approach in the accepted answer because my api gateway is already in use with the stage in the url. I needed to remove the stage for a particular route. For this example, this route: https://example.com/apple-app-site-association needs to hit api gateway route: https://example.com/v1/apple-app-site-association.

Using cloudfront,

in the Origins tab, create a new origin to point to the api gateway including the stage:

Origin Domain Name: example.com

Origin Path: /v1

Origin ID: (give this a unique name and note this for next step)

(Leave remaining settings as default or change as you require, I set Origin Protocol Policy: HTTPS Only)

in the Behaviors tab, create a new behavior:

Path Pattern: /apple-app-site-association

Origin: (the Origin ID you set above)

(Leave remaining settings as default or change as you require)