i am trying to build an api that consists of different services and i want to everything to start with /api/ path. like the following below.
i want https://thirdparthy/comments to be routed as /api/comments on express gateway. what is the correct confirmation?
http:
port: 4000
admin:
port: 9876
hostname: localhost
apiEndpoints:
users:
host: localhost
paths: '/api/users'
comments:
host: localhost
paths: '/api/comments'
serviceEndpoints:
users:
url: 'https://jsonplaceholder.typicode.com/users'
comments:
url: 'https://jsonplaceholder.typicode.com/comments'
policies:
- basic-auth
- cors
- expression
- key-auth
- log
- oauth2
- proxy
- rate-limit
pipelines:
users:
apiEndpoints:
- users
policies:
- proxy:
- action:
serviceEndpoint: users
prependPath: false
ignorePath: false
comments:
apiEndpoints:
- comments
policies:
- proxy:
- action:
serviceEndpoint: comments
prependPath: false
ignorePath: false
you can either use the rewrite
policy to change the target url or simply configure the proxy policy accordingly:
- proxy:
- action:
serviceEndpoint: comments
prependPath: true
ignorePath: false
This should do the job.
Cheers,
V.