Closed topsoft-support closed 4 years ago
I have seen this guide, create demo for test ,and it works fine. https://spring.io/guides/gs/routing-and-filtering/ the application.properties:zuul.routes.skd.url=http://localhost:8081/skd
application.properties
zuul.routes.skd.url=http://localhost:8081/skd
Now but my route for reverse proxy in my application will be set dynamically. I removed the zuul.routes.skd.url=http://localhost:8081/skd and do it like this:
if (path.startsWith("/skd/")) { ZuulProperties zuulProperties = applicationContext.getBean(ZuulProperties.class); System.out.println(zuulProperties); Map<String, ZuulProperties.ZuulRoute> routes = zuulProperties.getRoutes(); ZuulProperties.ZuulRoute zuulRoute = new ZuulProperties.ZuulRoute(); zuulRoute.setId("skd"); zuulRoute.setPath("/skd/**"); zuulRoute.setUrl("http://localhost:8081/skd"); zuulRoute.setStripPrefix(true) routes.put("skd", zuulRoute); zuulProperties.setRoutes(routes); filterChain.doFilter(servletRequest, servletResponse); }
but it doesn't work! anyone konw how to fix it?
I have seen this guide, create demo for test ,and it works fine. https://spring.io/guides/gs/routing-and-filtering/ the
application.properties
:zuul.routes.skd.url=http://localhost:8081/skd
Now but my route for reverse proxy in my application will be set dynamically. I removed the
zuul.routes.skd.url=http://localhost:8081/skd
and do it like this:but it doesn't work! anyone konw how to fix it?