From 11a0eedd52213dc3bb346cc16e581e9f14d20196 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Mon, 13 Jan 2025 17:47:44 +0100 Subject: [PATCH] DevUICORSFilter - Do not log errors for Chrome extensions This has been annoying me for a while, let's not log an error when a Chrome extension generates a request. --- .../main/java/io/quarkus/devui/runtime/DevUICORSFilter.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/DevUICORSFilter.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/DevUICORSFilter.java index ff8fd0c167f1e..1182bb4e6976c 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/DevUICORSFilter.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/devui/runtime/DevUICORSFilter.java @@ -25,6 +25,7 @@ public class DevUICORSFilter implements Handler { private static final String HTTPS_LOCAL_HOST = "https://" + LOCAL_HOST; private static final String HTTP_LOCAL_HOST_IP = "http://" + LOCAL_HOST_IP; private static final String HTTPS_LOCAL_HOST_IP = "https://" + LOCAL_HOST_IP; + private static final String CHROME_EXTENSION = "chrome-extension://"; public DevUICORSFilter() { } @@ -53,7 +54,9 @@ public void handle(RoutingContext event) { || origin.startsWith(HTTP_LOCAL_HOST_IP) || origin.startsWith(HTTPS_LOCAL_HOST_IP)) { corsFilter().handle(event); } else { - LOG.errorf("Only localhost origin is allowed, but Origin header value is: %s", origin); + if (!origin.startsWith(CHROME_EXTENSION)) { + LOG.errorf("Only localhost origin is allowed, but Origin header value is: %s", origin); + } response.setStatusCode(403); response.setStatusMessage("CORS Rejected - Invalid origin"); response.end();