Skip to content

Commit

Permalink
DevUICORSFilter - Do not log errors for Chrome extensions
Browse files Browse the repository at this point in the history
This has been annoying me for a while, let's not log an error when a
Chrome extension generates a request.
  • Loading branch information
gsmet committed Jan 13, 2025
1 parent 429c2d0 commit 11a0eed
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class DevUICORSFilter implements Handler<RoutingContext> {
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() {
}
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 11a0eed

Please sign in to comment.