Skip to content

Commit

Permalink
Add a redirect for /spa and lower required core version
Browse files Browse the repository at this point in the history
  • Loading branch information
ibacher committed May 30, 2024
1 parent b3a3c68 commit 5ef25b9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion omod/src/main/java/org/openmrs/module/spa/SpaController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -105,7 +107,7 @@ public ResponseEntity<Resource> 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<Resource> getSinglePage() {
Resource resource = resourceLoader.getResource("/index.html");
if (resource.exists()) {
Expand All @@ -118,4 +120,9 @@ public ResponseEntity<Resource> getSinglePage() {
return ResponseEntity.notFound().build();
}
}

@RequestMapping("")
public ResponseEntity<Resource> index(HttpServletRequest request) {
return ResponseEntity.status(HttpStatus.MOVED_PERMANENTLY).location(URI.create(request.getContextPath() + "/spa/")).build();
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</modules>

<properties>
<openMRSVersion>2.6.5</openMRSVersion>
<openMRSVersion>2.4.1</openMRSVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand Down

0 comments on commit 5ef25b9

Please sign in to comment.