diff --git a/src/main/java/org/hl7/davinci/priorauth/endpoint/Metadata.java b/src/main/java/org/hl7/davinci/priorauth/endpoint/Metadata.java index e897fc4d..5eebd9e6 100644 --- a/src/main/java/org/hl7/davinci/priorauth/endpoint/Metadata.java +++ b/src/main/java/org/hl7/davinci/priorauth/endpoint/Metadata.java @@ -171,7 +171,11 @@ private CapabilityStatementRestSecurityComponent getSecurity(HttpServletRequest CapabilityStatementRestSecurityComponent security = new CapabilityStatementRestSecurityComponent(); security.setCors(true); Extension oauthUris = new Extension("http://fhir-registry.smarthealthit.org/StructureDefinition/oauth-uris"); - String uriBase = request.getRequestURL().toString().replace(request.getRequestURI(), ""); + String uriBase = request.getScheme() + "://" + request.getServerName() + + ("http".equals(request.getScheme()) && request.getServerPort() == 80 + || "https".equals(request.getScheme()) && request.getServerPort() == 443 ? "" + : ":" + request.getServerPort()); + if (System.getenv("TOKEN_BASE_URI") != null && !System.getenv("TOKEN_BASE_URI").isBlank()) { uriBase = System.getenv("TOKEN_BASE_URI"); }