Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS API Gateway - Remove Stage Name From URI

The stage name is added to the url when I deploy the API. Let's say the stage name is "test", then the generated URL for the resource includes the stage name. Something like: https://abcabc.execute-api.us-east-1.amazonaws.com/test/my/path

I would like to remove the stage name in the URL. How can I do it?

like image 503
evansgambit Avatar asked Sep 16 '16 03:09

evansgambit


People also ask

How do I remove API gateway stage?

Sign in to the API Gateway console at https://console.aws.amazon.com/apigateway . Choose a REST API. Choose Stages. In the Stages pane, choose the stage you want to delete, and then choose Delete Stage.

How do I change API gateway invoke URL?

If you want to change the URL of the integration endpoint, you need to open the "Integration Request" tab on the method settings, make sure the integration type is set to "HTTP Proxy" and update the "Endpoint URL" field.

What is stage in AWS API gateway?

A stage is a named reference to a deployment, which is a snapshot of the API. You use a Stage to manage and optimize a particular deployment. For example, you can configure stage settings to enable caching, customize request throttling, configure logging, define stage variables, or attach a canary release for testing.

How do I change my API gateway name on AWS?

Under the Amazon API Gateway service, select APIs . You will see the list of your APIs. Now, click the little cog wheel in the top right corner of the API that you wish to rename... Simply change the name, hit save, and you're good!


2 Answers

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

like image 100
RyanG Avatar answered Oct 04 '22 06:10

RyanG


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)

like image 42
joshweir Avatar answered Oct 04 '22 06:10

joshweir



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!