Skip to content

Commit 034f842

Browse files
RomuDeuxfoisrichard-julien
authored andcommitted
[backend] Handle back-end routes (#473)
1 parent dd4c55b commit 034f842

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

openex-api/src/main/java/io/openex/rest/HomeApi.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import org.springframework.web.bind.annotation.GetMapping;
1111
import org.springframework.web.bind.annotation.RestController;
1212

13-
import javax.servlet.http.HttpServletRequest;
1413
import java.io.IOException;
1514
import java.io.InputStreamReader;
1615
import java.io.Reader;
@@ -32,19 +31,19 @@ private static String readResourceAsString(Resource resource) {
3231
@Value("${server.servlet.context-path}")
3332
private String contextPath;
3433

35-
@GetMapping(path = {"/", "/admin/**", "/players/**"}, produces = MediaType.TEXT_HTML_VALUE)
34+
@GetMapping(path = {"/", "/{path:^(?!api$|login$|logout$|oauth2$|saml2$|static$).*$}/**"}, produces = MediaType.TEXT_HTML_VALUE)
3635
public ResponseEntity<String> home() {
3736
ClassPathResource classPathResource = new ClassPathResource("/build/index.html");
3837
String index = readResourceAsString(classPathResource);
39-
String basePath = contextPath.endsWith("/") ? contextPath.substring(0, contextPath.length() - 1) : contextPath;
38+
String basePath = this.contextPath.endsWith("/") ? this.contextPath.substring(0, this.contextPath.length() - 1) : this.contextPath;
4039
String newIndex = index.
41-
replaceAll("%APP_TITLE%", "OpenEx - Crisis Exercises and Adversary Simulation Platform").
42-
replaceAll("%APP_DESCRIPTION%", "OpenEx is an open source platform allowing organizations to plan, schedule and conduct crisis exercises as well as adversary simulation campaign.").
43-
replaceAll("%APP_FAVICON%", basePath + "/static/ext/favicon.png").
44-
replaceAll("%APP_MANIFEST%", basePath + "/static/ext/manifest.json").
45-
replaceAll("%BASE_PATH%", basePath);
40+
replaceAll("%APP_TITLE%", "OpenEx - Crisis Exercises and Adversary Simulation Platform").
41+
replaceAll("%APP_DESCRIPTION%", "OpenEx is an open source platform allowing organizations to plan, schedule and conduct crisis exercises as well as adversary simulation campaign.").
42+
replaceAll("%APP_FAVICON%", basePath + "/static/ext/favicon.png").
43+
replaceAll("%APP_MANIFEST%", basePath + "/static/ext/manifest.json").
44+
replaceAll("%BASE_PATH%", basePath);
4645
return ResponseEntity.ok()
47-
.header(HttpHeaders.CACHE_CONTROL, "no-cache")
48-
.body(newIndex);
46+
.header(HttpHeaders.CACHE_CONTROL, "no-cache")
47+
.body(newIndex);
4948
}
5049
}

0 commit comments

Comments
 (0)