Skip to content

Commit

Permalink
Add DevConsoleCORSFilter to Dev UI JsonRPC WebSocket
Browse files Browse the repository at this point in the history
Signed-off-by: Phillip Kruger <[email protected]>
  • Loading branch information
phillip-kruger committed May 29, 2023
1 parent 588f287 commit 06c59a5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.vertx.http.deployment.devmode.console;
package io.quarkus.devui.deployment;

import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import io.quarkus.vertx.http.deployment.webjar.WebJarBuildItem;
import io.quarkus.vertx.http.deployment.webjar.WebJarResourcesFilter;
import io.quarkus.vertx.http.deployment.webjar.WebJarResultsBuildItem;
import io.quarkus.vertx.http.runtime.devmode.DevConsoleCORSFilter;
import io.smallrye.common.annotation.Blocking;
import io.smallrye.common.annotation.NonBlocking;
import io.smallrye.mutiny.Multi;
Expand Down Expand Up @@ -120,6 +121,7 @@ public class DevUIProcessor {
@BuildStep(onlyIf = IsDevelopment.class)
@Record(ExecutionTime.STATIC_INIT)
void registerDevUiHandlers(
DevUIConfig devUIConfig,
MvnpmBuildItem mvnpmBuildItem,
List<DevUIRoutesBuildItem> devUIRoutesBuildItems,
List<StaticContentBuildItem> staticContentBuildItems,
Expand All @@ -133,6 +135,13 @@ void registerDevUiHandlers(
return;
}

if (devUIConfig.cors.enabled) {
routeProducer.produce(nonApplicationRootPathBuildItem.routeBuilder()
.route(DEVUI + SLASH_ALL)
.handler(new DevConsoleCORSFilter())
.build());
}

// Websocket for JsonRPC comms
routeProducer.produce(
nonApplicationRootPathBuildItem
Expand All @@ -155,8 +164,8 @@ void registerDevUiHandlers(
.route(route)
.handler(uihandler);

if (route.endsWith(DEVUI)) {
builder = builder.displayOnNotFoundPage("Dev UI 2.0");
if (route.endsWith(DEVUI + SLASH)) {
builder = builder.displayOnNotFoundPage("Dev UI (v2)");
routeProducer.produce(builder.build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import io.quarkus.devconsole.spi.DevConsoleRuntimeTemplateInfoBuildItem;
import io.quarkus.devconsole.spi.DevConsoleTemplateInfoBuildItem;
import io.quarkus.devconsole.spi.DevConsoleWebjarBuildItem;
import io.quarkus.devui.deployment.DevUIConfig;
import io.quarkus.maven.dependency.ArtifactKey;
import io.quarkus.maven.dependency.GACT;
import io.quarkus.netty.runtime.virtual.VirtualChannel;
Expand Down

0 comments on commit 06c59a5

Please sign in to comment.