Skip to content

Commit

Permalink
Always add CORS headers
Browse files Browse the repository at this point in the history
  • Loading branch information
haideriqbal committed Dec 5, 2024
1 parent 7dde027 commit 8388527
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpServletResponse httpResponse = (HttpServletResponse) response;

// Alwasy add CORS headers. add CORS "pre-flight" request headers
httpResponse.addHeader("Access-Control-Allow-Origin", "*");
httpResponse.addHeader("Access-Control-Allow-Headers", "*");
httpResponse.addHeader("Access-Control-Allow-Methods", "GET");
httpResponse.addHeader("Access-Control-Max-Age", "3600");

// is this a CORS request?
if (httpRequest.getHeader("Origin") != null) {
String origin = httpRequest.getHeader("Origin");
String requestURI = httpRequest.getRequestURI();
getLog().trace("Possible cross-origin request received from '" + origin + "' to IRI: " +
"'" + requestURI + "'. Enabling CORS.");

// add CORS "pre-flight" request headers
httpResponse.addHeader("Access-Control-Allow-Origin", "*");
httpResponse.addHeader("Access-Control-Allow-Headers", "*");
httpResponse.addHeader("Access-Control-Allow-Methods", "GET");
}

chain.doFilter(request, response);
Expand Down

0 comments on commit 8388527

Please sign in to comment.