For the complete documentation index, see llms.txt. This page is also available as Markdown.

Add and Remove Prefix

Add or remove URL path prefixes when proxying requests in the Serverless API Gateway. Rewrite or strip path segments before forwarding to upstream 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:

With this configuration, GET https://api.yourdomain.com/prefix/path will be proxied to GET https://sub.serverlessapigw.com/path.

See Also

  • Paths -- full reference for path-based routing configuration including methods, auth, and mappings.

  • Servers -- define the upstream server aliases used in prefix-based routing.

Last updated