Adding a prefix to the path

Sometimes it is necessary to set a different path for services invoked via a gateway rather than allow them being available directly. In that case, Zuul provides the ability to add prefixes to all the defined mappings. This may be easily configured with the zuul.prefix property. By default, Zuul cuts that prefix before forwarding requests to the services. However, that behavior can also be disabled by setting the zuul.stripPrefix property to false. A stripPrefix property may be configured not only globally for all defined routes, but also per single route.

Here's an example that adds the /api prefix to all the forwarded requests. Now, for example, if you would like to call the GET /{id} endpoint from account-service ...

Get Mastering Spring Cloud now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.