# API gateway: same base URLs for my APIs?

**URL:** <https://forum.serverless.com/t/api-gateway-same-base-urls-for-my-apis/674>\
**Category:** Serverless Framework\
**Tags:** aws\
**Created:** [October 27, 2016, 11:49pm UTC](https://forum.serverless.com/t/api-gateway-same-base-urls-for-my-apis/674 "2016-10-27T23:49:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![endymion](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/endymion/32/178_2.png) [@endymion](https://forum.serverless.com/u/endymion)\
**Post date:** [October 27, 2016, 11:49pm UTC](https://forum.serverless.com/t/api-gateway-same-base-urls-for-my-apis/674/1 "2016-10-27T23:49:29Z")

</div>

Hi,

I’ve architected some microservices exposed as APIs on amazon API Gateway.  
Every API is a different serverless project (user api, auth api, etc.).  
The problem I face is that every deployed API has a different base URL.

Example:

Auth API [https://12323232.execute-api.eu-central-1.amazonaws.com/dev](https://12323232.execute-api.eu-central-1.amazonaws.com/dev)  
User API [https://5555553.execute-api.eu-central-1.amazonaws.com/dev](https://5555553.execute-api.eu-central-1.amazonaws.com/dev)

My question is:

**Can I use the same base URL for all my APIs?**  
That is:  
[https://fixedbaseurl/dev/users](https://fixedbaseurl/dev/users)  
[https://fixedbaseurl/dev/auth](https://fixedbaseurl/dev/auth)

instead of  
[https://12323232.execute-api.eu-central-1.amazonaws.com/dev/auth](https://12323232.execute-api.eu-central-1.amazonaws.com/dev/auth)  
[https://5555553.execute-api.eu-central-1.amazonaws.com/dev/users](https://5555553.execute-api.eu-central-1.amazonaws.com/dev/users)

---

<div class="post-metadata">

**Author:** ![endymion](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/endymion/32/178_2.png) [@endymion](https://forum.serverless.com/u/endymion)\
**Post date:** [October 28, 2016, 11:19am UTC](https://forum.serverless.com/t/api-gateway-same-base-urls-for-my-apis/674/2 "2016-10-28T11:19:59Z")

</div>

Here is more info:

[http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html](http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html)  
(see section Base Path Examples of API Mappings for a Custom Domain Name)

It would be great if this could be automated. I don’t know if there any other solution.

---

<div class="post-metadata">

**Author:** ![martinmicunda](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/martinmicunda/32/204_2.png) [@martinmicunda](https://forum.serverless.com/u/martinmicunda)\
**Post date:** [October 28, 2016, 1:38pm UTC](https://forum.serverless.com/t/api-gateway-same-base-urls-for-my-apis/674/3 "2016-10-28T13:38:36Z")

</div>

Hi,

I am facing exactly same issue (I have 15 microservices at the moment) and I can tell what you try to achieve is not possible with serverless at the moment.

Even if you would be able to pass same base URL for all your APIs this would basically remove all your previous changes from other serveless services. Currently when you deploy API Gateway through serverless it basically replace previous API Gateway changes so if you have 2 serverless projects and you deploy `auth` and then `user` to api gateway you will end up only with users endpoints no auth endpoints because serveless doesn’t know anything about your endpoints from `auth` project.

I spoke with @flomotlik about this issue in London Serveless conf and they are actually working on solution as this is a pain for people that try to develop medium or large projects with many services and endpoints. My understanding is that in the future you should be able to create new serverless project just for api gateway where you specify all endpoints and function names (you don’t want to hard code the function names and instead this value should come from output of other serverless projects e.g during the CI deployment).

If you can’t wait till this feature will be add to serveless framework I would suggest to use cloudfromation and swagger for now.

---

<div class="post-metadata">

**Author:** ![endymion](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/endymion/32/178_2.png) [@endymion](https://forum.serverless.com/u/endymion)\
**Post date:** [October 28, 2016, 9:30pm UTC](https://forum.serverless.com/t/api-gateway-same-base-urls-for-my-apis/674/4 "2016-10-28T21:30:56Z")

</div>

Hi @martinmicunda,  
Than you for your message.  
Could you give me some more detail about do it by using cloudformation and swagger?  
I suppose cloudformation templates generated by serveless could be useful…

---

<div class="post-metadata">

**Author:** ![martinmicunda](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/martinmicunda/32/204_2.png) [@martinmicunda](https://forum.serverless.com/u/martinmicunda)\
**Post date:** [October 29, 2016, 10:50am UTC](https://forum.serverless.com/t/api-gateway-same-base-urls-for-my-apis/674/5 "2016-10-29T10:50:29Z")

</div>

@endymion here are a few resources that might help you to start

[https://sookocheff.com/post/api/deploying-swagger-to-api-gateway/](https://sookocheff.com/post/api/deploying-swagger-to-api-gateway/)  
[http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions.html](http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions.html)  
[https://www.jayway.com/2016/09/18/introduction-swagger-cloudformation-api-gateway](https://www.jayway.com/2016/09/18/introduction-swagger-cloudformation-api-gateway)

---

<div class="post-metadata">

**Author:** ![buggy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/buggy/32/177_2.png) [@buggy](https://forum.serverless.com/u/buggy)\
**Post date:** [November 1, 2016, 11:07pm UTC](https://forum.serverless.com/t/api-gateway-same-base-urls-for-my-apis/674/6 "2016-11-01T23:07:11Z")

</div>

Could you setup one API GW to proxy all of the other API GW’s?
