forked from usdot-jpo-ode/jpo-cvmanager
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
171 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 33 additions & 33 deletions
66
jpo-conflictvisualizer-api/src/main/java/us/dot/its/jpo/ode/api/CorsFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
package us.dot.its.jpo.ode.api; | ||
|
||
import jakarta.servlet.*; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Custom servlet filter to add CORS header | ||
*/ | ||
public class CorsFilter implements Filter { | ||
@Override | ||
public void init(FilterConfig filterConfig) throws ServletException { | ||
// Nothing to initialize | ||
} | ||
|
||
@Override | ||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { | ||
var response = (HttpServletResponse)servletResponse; | ||
var request = (HttpServletRequest)servletRequest; | ||
response.setHeader("Access-Control-Allow-Origin", "*"); | ||
response.setHeader("Access-Control-Allow-Methods", "OPTIONS,GET,POST,DELETE"); | ||
response.setHeader("Access-Control-Allow-Headers", "authorization"); | ||
response.setIntHeader("Access-Control-Max-Age", 1800); | ||
filterChain.doFilter(servletRequest, servletResponse); | ||
} | ||
|
||
@Override | ||
public void destroy() { | ||
// Nothing to destroy | ||
} | ||
} | ||
//package us.dot.its.jpo.ode.api; | ||
// | ||
//import jakarta.servlet.*; | ||
//import jakarta.servlet.http.HttpServletRequest; | ||
//import jakarta.servlet.http.HttpServletResponse; | ||
// | ||
//import java.io.IOException; | ||
// | ||
///** | ||
// * Custom servlet filter to add CORS header | ||
// */ | ||
//public class CorsFilter implements Filter { | ||
// @Override | ||
// public void init(FilterConfig filterConfig) throws ServletException { | ||
// // Nothing to initialize | ||
// } | ||
// | ||
// @Override | ||
// public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { | ||
// var response = (HttpServletResponse)servletResponse; | ||
// var request = (HttpServletRequest)servletRequest; | ||
// response.setHeader("Access-Control-Allow-Origin", "*"); | ||
// response.setHeader("Access-Control-Allow-Methods", "OPTIONS,GET,POST,DELETE"); | ||
// response.setHeader("Access-Control-Allow-Headers", "authorization"); | ||
// response.setIntHeader("Access-Control-Max-Age", 1800); | ||
// filterChain.doFilter(servletRequest, servletResponse); | ||
// } | ||
// | ||
// @Override | ||
// public void destroy() { | ||
// // Nothing to destroy | ||
// } | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters