diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2022-10-27 16:13:04 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2022-10-27 16:24:39 +0200 |
| commit | 5a3d5148a9d52487f102e52bd079006c916075c9 (patch) | |
| tree | 8dad74b6a213bb294dbcea33ebab34a3be193e77 /opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org | |
| parent | 5e2a42a58b2cf4d1b94d5568e7c74373a4759bc3 (diff) | |
fix(web/ui): Disable configuration of basePath
This change removes the ability to configure the basePath of the Next.js
application using the Quarkus extension. This functionality was brittle
due to relying on Next.js internals coping with out replacement
strategy.
We should wait for Next.js to implement proper support for
changing the base path at runtime before making this functionality
available again.
Diffstat (limited to 'opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org')
2 files changed, 8 insertions, 28 deletions
diff --git a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiConfig.java b/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiConfig.java index d630dbac..091e60ab 100644 --- a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiConfig.java +++ b/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiConfig.java @@ -38,12 +38,6 @@ public class OpenDCUiConfig { boolean include; /** - * The path where the OpenDC UI is available. - */ - @ConfigItem(defaultValue = "/") - String path; - - /** * The base URL of the OpenDC API. */ @ConfigItem(defaultValue = "/api") diff --git a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiProcessor.java b/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiProcessor.java index 093a9bfa..5733e0db 100644 --- a/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiProcessor.java +++ b/opendc-web/opendc-web-ui-quarkus-deployment/src/main/java/org/opendc/web/ui/deployment/OpenDCUiProcessor.java @@ -75,13 +75,13 @@ public class OpenDCUiProcessor { * Build the WebJar that is used to serve the Next.js resources. */ @BuildStep(onlyIf = IsIncluded.class) - public WebJarBuildItem buildWebJar(OpenDCUiConfig config, HttpRootPathBuildItem httpRootPathBuildItem) { + public WebJarBuildItem buildWebJar(OpenDCUiConfig config) { return WebJarBuildItem.builder() .artifactKey(OPENDC_UI_WEBJAR_ARTIFACT_KEY) .root(OPENDC_UI_WEBJAR_STATIC_RESOURCES_PATH) .onlyCopyNonArtifactFiles(false) .useDefaultQuarkusBranding(false) - .filter(new InsertVariablesResourcesFilter(config, httpRootPathBuildItem)) + .filter(new InsertVariablesResourcesFilter(config)) .build(); } @@ -128,8 +128,8 @@ public class OpenDCUiProcessor { } int statusCode = redirect.get("statusCode").asInt(); - String path = redirect.get("source").asText().replaceAll("/%%NEXT_BASE_PATH%%", ""); - String destination = redirect.get("destination").asText().replaceAll("/%%NEXT_BASE_PATH%%", ""); + String path = redirect.get("source").asText(); + String destination = redirect.get("destination").asText(); if (path.isEmpty()) { path = "/"; @@ -154,7 +154,6 @@ public class OpenDCUiProcessor { WebJarResultsBuildItem webJarResultsBuildItem, OpenDCUiRoutingBuildItem openDCUiBuildItem, OpenDCUiRuntimeConfig runtimeConfig, - OpenDCUiConfig buildConfig, ShutdownContextBuildItem shutdownContext) { WebJarResultsBuildItem.WebJarResult result = @@ -163,7 +162,7 @@ public class OpenDCUiProcessor { return; } - String basePath = httpRootPathBuildItem.resolvePath(buildConfig.path); + String basePath = httpRootPathBuildItem.getRootPath(); String finalDestination = result.getFinalDestination(); /* Construct dynamic routes */ @@ -192,15 +191,7 @@ public class OpenDCUiProcessor { routes.produce(httpRootPathBuildItem .routeBuilder() - .route(buildConfig.path) - .displayOnNotFoundPage("OpenDC UI") - .routeConfigKey("quarkus.opendc-ui.path") - .handler(staticHandler) - .build()); - - routes.produce(httpRootPathBuildItem - .routeBuilder() - .route(buildConfig.path + "*") + .route("*") .handler(staticHandler) .build()); } @@ -215,11 +206,9 @@ public class OpenDCUiProcessor { private static final String JS = ".js"; private final OpenDCUiConfig config; - private final HttpRootPathBuildItem httpRootPathBuildItem; - public InsertVariablesResourcesFilter(OpenDCUiConfig config, HttpRootPathBuildItem httpRootPathBuildItem) { + public InsertVariablesResourcesFilter(OpenDCUiConfig config) { this.config = config; - this.httpRootPathBuildItem = httpRootPathBuildItem; } @Override @@ -247,9 +236,6 @@ public class OpenDCUiProcessor { private String substitute(String var) { switch (var) { - case "NEXT_BASE_PATH": - String basePath = httpRootPathBuildItem.resolvePath(config.path); - return basePath.equals("/") ? "" : basePath; // Base path must not end with trailing slash case "NEXT_PUBLIC_API_BASE_URL": return config.apiBaseUrl; case "NEXT_PUBLIC_SENTRY_DSN": @@ -271,7 +257,7 @@ public class OpenDCUiProcessor { * Be aware that to properly handle Next.js base path, we need to also match a possible forward slash in front * of the variable. */ - private static final Pattern PATTERN = Pattern.compile("/?%%(\\w+)%%"); + private static final Pattern PATTERN = Pattern.compile("%%(\\w+)%%"); /** * Helper method to substitute variables in the OpenDC web UI. |
