-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # pom.xml # src/main/java/org/teapot/backend/controller/user/UserController.java
- Loading branch information
Showing
3 changed files
with
45 additions
and
0 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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.teapot.backend.filters; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
import javax.servlet.*; | ||
import javax.servlet.http.HttpServletResponse; | ||
import java.io.IOException; | ||
|
||
@Component | ||
public class CorsFilter implements Filter { | ||
|
||
@Override | ||
public void doFilter(ServletRequest servletRequest, | ||
ServletResponse servletResponse, | ||
FilterChain filterChain) | ||
throws IOException, ServletException { | ||
|
||
HttpServletResponse response = (HttpServletResponse) servletResponse; | ||
|
||
response.setHeader("Access-Control-Allow-Origin", "*"); | ||
response.setHeader("Access-Control-Allow-Methods", | ||
"POST, GET, PUT, PATCH, DELETE, OPTIONS"); | ||
response.setHeader("Access-Control-Max-Age", "3600"); | ||
response.setHeader("Access-Control-Allow-Headers", | ||
"x-requested-with, Content-Type, Authorization, Accept"); | ||
|
||
filterChain.doFilter(servletRequest, servletResponse); | ||
} | ||
|
||
@Override | ||
public void init(FilterConfig filterConfig) throws ServletException { | ||
} | ||
|
||
@Override | ||
public void destroy() { | ||
} | ||
} |