From 5ef25b97a5df74903347241eba4db51e80b70d65 Mon Sep 17 00:00:00 2001 From: Ian Date: Thu, 30 May 2024 15:29:47 -0400 Subject: [PATCH] Add a redirect for /spa and lower required core version --- .../main/java/org/openmrs/module/spa/SpaController.java | 9 ++++++++- pom.xml | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/omod/src/main/java/org/openmrs/module/spa/SpaController.java b/omod/src/main/java/org/openmrs/module/spa/SpaController.java index adb85aa..1af5e10 100644 --- a/omod/src/main/java/org/openmrs/module/spa/SpaController.java +++ b/omod/src/main/java/org/openmrs/module/spa/SpaController.java @@ -7,6 +7,7 @@ import org.springframework.core.io.Resource; import org.springframework.http.CacheControl; import org.springframework.http.HttpRequest; +import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; @@ -15,6 +16,7 @@ import javax.servlet.http.HttpServletRequest; import java.io.IOException; +import java.net.URI; import java.net.URLConnection; import java.nio.file.Files; import java.time.Instant; @@ -105,7 +107,7 @@ public ResponseEntity getStaticFile(HttpServletRequest request) { * file. Like {@link #getStaticFileWithoutCacheHeaders(String)}, this attempts to force the client to always reload * this resource. */ - @RequestMapping({"/**/{filename:.?(?!.*\\.[^.]*$).*$}", "*.html", "*.htm"}) + @RequestMapping({ "/", "/**/{filename:.?(?!.*\\.[^.]*$).*$}", "*.html", "*.htm"}) public ResponseEntity getSinglePage() { Resource resource = resourceLoader.getResource("/index.html"); if (resource.exists()) { @@ -118,4 +120,9 @@ public ResponseEntity getSinglePage() { return ResponseEntity.notFound().build(); } } + + @RequestMapping("") + public ResponseEntity index(HttpServletRequest request) { + return ResponseEntity.status(HttpStatus.MOVED_PERMANENTLY).location(URI.create(request.getContextPath() + "/spa/")).build(); + } } diff --git a/pom.xml b/pom.xml index fd671f8..69edf5c 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ - 2.6.5 + 2.4.1 UTF-8