Skip to content

Commit b504042

Browse files
committed
Only append port to forwarded header in not already there.
1 parent a9ba9c3 commit b504042

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/filter/ForwardedRequestHeadersFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public HttpHeaders apply(HttpHeaders input, ServerRequest request) {
162162
return;
163163
}
164164
int port = remoteAddress.getPort();
165-
if (port >= 0) {
165+
if (port >= 0 && !forValue.endsWith(":" + port)) {
166166
forValue = forValue + ":" + port;
167167
}
168168
forwarded.put("for", forValue);

0 commit comments

Comments
 (0)