spring-cloud / spring-cloud/spring-cloud-gateway
How to include the service's context-path when the gateway forwards requests
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.9k
- Forks
- 3.5k
- Avg merge
- 20h 57m
- Merged PRs (30d)
- 8
Description
Springcloud Version: 2025.0.1
spring-cloud-starter-gateway-server-webflux: 4.3.3
nacos server: 3.0.3
Configuration as follows
spring: jackson: date-format: yyyy-MM-dd HH:mm:ss time-zone: GMT+8 cloud: gateway: server: webflux: discovery: locator: enabled: true lowerCaseServiceId: true # urlExpression: "'lb://' + serviceId + metadata['contextPath']"
Even if urlExpression is configured
Still unable to forward with context path
So how should I configure it ?
My idea is if there is any configuration where I can directly read the context path value in the metadata of the Nacos service registration information, so that I don't need to manually configure the routing
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Spring Cloud Gateway WebFlux discovery locator configuration and its urlExpression, then inspect how Nacos service metadata is exposed to route construction. Verify whether the registered context path can be read automatically and confirm that forwarded requests include it without manually configured routes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring-boot
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100