diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/IncomingRequestAddressStrategy.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/IncomingRequestAddressStrategy.java index 1edad7968d5..b2f72cc0e40 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/IncomingRequestAddressStrategy.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/IncomingRequestAddressStrategy.java @@ -73,7 +73,12 @@ public class IncomingRequestAddressStrategy implements IServerAddressStrategy { } String fhirServerBase; - int length = contextIndex + servletPath.length(); + int length; + if (servletContextPath.length() == 0 || servletContextPath.equals("/")) { + length = contextIndex + servletPath.length(); + } else { + length = contextIndex + servletPath.length() + servletContextPath.length(); + } if (length > requestUrlLength) { length = requestUrlLength; }