I want to re-write my URL to map to a specific service path. I want to route /orders to /api/v1/ on the micro service. An example full endpoint could be /orders, and it would map to the microservice at this full endpoint /api/v1/function1.

I'm using Eureka Service Discovery, so I can't use uri. Here is my application.properties:

zuul.routes.orders.path=/orders/**
zuul.routes.orders.serviceId=order-service
zuul.routes.orders.stripPrefix= true

I tried using a custom path filter as mentioned here

    @Override
    public Object run() {
        RequestContext context = RequestContext.getCurrentContext();
        Object originalRequestPath = context.get(REQUEST_URI_KEY);
        String modifiedRequestPath = "/api/microservicePath" + originalRequestPath;
        context.put(REQUEST_URI_KEY, modifiedRequestPath);

        return null;
    }

Comment From: OlgaMaciaszek

Hello @nazrul-kabir. Spring Cloud Netflix Zuul has been out of support for quite some time now. We strongly recommend migrating over to Spring Cloud Gateway in order to avoid security issues.

Comment From: taasjord

I did it just like that, with a custom path filter, with the only difference i supplied custom configuration properties to not hard code the path on the service. And I had a specific order on it:

// Must run after the pre-decoration filter
protected static final int FILTER_ORDER =  PRE_DECORATION_FILTER_ORDER + 1;

Comment From: moa-oma

When I saw this, I gave up completely

Comment From: moa-oma

Rewrite the RequestContext requestURI only using Filter before RibbonRoutingFilter

Comment From: OlgaMaciaszek

Please do not use Spring Cloud Netflix Zuul. It has been out of maintenance for years now. You're exposing yourself to security vulnerabilities by using it. Please use Spring Cloud Gateway.