From 8bc1b8d2bba22d9a8e2571c55dcefc9c343a4e19 Mon Sep 17 00:00:00 2001 From: Gayan Weerakutti Date: Mon, 9 Oct 2017 12:01:14 +0530 Subject: [PATCH] fixup --- .../web/controller/SwaggerSpecificationController.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/omod/src/main/java/org/openmrs/module/webservices/rest/web/controller/SwaggerSpecificationController.java b/omod/src/main/java/org/openmrs/module/webservices/rest/web/controller/SwaggerSpecificationController.java index e84d06601..213c9386e 100644 --- a/omod/src/main/java/org/openmrs/module/webservices/rest/web/controller/SwaggerSpecificationController.java +++ b/omod/src/main/java/org/openmrs/module/webservices/rest/web/controller/SwaggerSpecificationController.java @@ -9,6 +9,7 @@ */ package org.openmrs.module.webservices.rest.web.controller; +import com.google.common.net.HttpHeaders; import io.swagger.models.Scheme; import org.openmrs.module.webservices.docs.swagger.SwaggerSpecificationCreator; import org.springframework.stereotype.Controller; @@ -31,10 +32,15 @@ String getSwaggerSpecification(HttpServletRequest request) throws Exception { host += ":" + request.getServerPort(); } + String scheme = request.getHeader(HttpHeaders.X_FORWARDED_PROTO); + if (scheme == null) { + scheme = request.getScheme(); + } + return new SwaggerSpecificationCreator() .host(host) .basePath(request.getContextPath() + "/ws/rest/v1") - .scheme(Scheme.forValue(request.getScheme())) + .scheme(Scheme.forValue(scheme)) .BuildJSON(); }