简体   繁体   中英

AWS API Gateway Custom Domain with multi path

I have some services registered at API Gateway with Lambda serverless deployment. Both services are running well with long domain named from AWS API Gateway itself. Then, I am trying to setup a custom domain to gathered all services into one domain and splitting services by path.

Here is the example I wanted to do (2 Services example):

1. User Service registered on user-api-service Gateway API

2. Order Service registered on order-api-service Gateway API

I want to add custom domain with these settings:

1. api.myapp.com/user path with destination user-api-service Gateway
    API
2. api.myapp.com/order path with destination order-api-service Gateway
    API

I have tried to set this up but it is not work. And this is the problem:

THE PATH ALWAYS USING ROOT !

Whatever I did, It is never use the defined path. And only the first registered mapping is working !

Based on my setting:

api.myapp.com/user/register should be called for register, but it's not work. It is said 404 or Not Found

But it is working with root path:

api.myapp.com/register

Any custom setup that the documentation of API Gateway is not telling ?

What should I do with this error ?

I am assuming you have created your custom domain and attached it to API gateway for base path mapping. Considering this, you can add Base path mapping with custom base path just as you wanted do.

  1. Go to API gateway in AWS console
  2. Scroll down to Custom Domain Names
  3. Here you will see your custom domain
  4. Click on EDIT option
  5. Now you can add mapping as "user" or "order" and select which service you need to attach this base path to "api.myapp.com/user/*"

After saving this settings you are able to run API on

Note: You can not use same base path for other service if you have already attached it before.

In case you haven't created a custom domain, first create custom domain in Route 53 and then add that custom domain to API gateway custom domain section to process further

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM