Kong Rewrite URL

Is it true that Kong Community Edition can’t rewrite url paths without using 3rd party or custom plugins? The documentation for the Request Transformer and Request Transformer Advanced seem to suggest this.

For example:

  • Request for /useful-endpoint arrives at Kong
  • Kong transforms uri path to /api/useful-endpoint and sends the request to a proxied server.

I’m surprised (and disappointed) that this is considered “Enterprise” level functionality.

Is there something obvious I’m missing?

No. This is not an Enterprise feature. It has been a feature in Kong even before the enterprise product even existed.

You can create a route with /useful-endpoint as one of the paths, and then in the service entity, set the path property to /api.

Docs here:

Excellent! I was definitely confused, I can see where I went wrong now. I couldn’t imagine that would be something only found in Enterprise. Thanks for taking a moment to answer my question.

What about scenarios where path variables are involved?

  • Request for /new/123/info arrives at Kong (where 123 could be any numeric type id)
  • Is modified to /legacy/123/detail

request-transformer-advanced capabilities are now available in the open-source request-transformer plugin (the docs are out of date, unfortunately).

You can use regex captures and substitution for your use-case:

2 Likes

Hello @hbagdi, those are great news. As this is not documented, could you share the codebase that was integrated into request-transformer from request-transformer-advanced?

We were looking at https://github.com/Kong/kong-plugin-request-transformer and couldn’t spot new changes.