Add and Remove Prefix
Path and proxy structure let you add prefixes to path before passing request to servers.
{
...
"servers": [
{
"alias": "prefixing",
"url": "https://sub.serverlessapigw.com/prefix/"
},
...
],
...
"paths": [
{
"method": "GET",
"path": "/{.+}",
"integration": {
"type": "http_proxy",
"server": "prefixing"
}
},
```
With the above configuration, any GET request to the API will be proxied to 'https://sub.serverlessapigw.com/prefix'
.
For example: GET https://api.yourdomain.com/path
will be proxied to GET https://sub.serverlessapigw.com/prefix/path
.
This method can also be used to remove a portion of the path from the beginning:
{
...
"servers": [
{
"alias": "prefixing",
"url": "https://sub.serverlessapigw.com"
},
...
],
...
"paths": [
{
"method": "GET",
"path": "/prefix/{.+}",
"integration": {
"type": "http_proxy",
"server": "prefixing"
}
},
```
With this configuration, GET https://api.yourdomain.com/prefix/path
will be proxied to GET https://sub.serverlessapigw.com/path
.
Last updated