Skip to content

Commit

Permalink
Merge pull request #117 from 0702Yoon/main
Browse files Browse the repository at this point in the history
refactor : cors 에러를 방지한 와일드 카드 도입
  • Loading branch information
0702Yoon authored Aug 20, 2024
2 parents ed19e52 + 0044d88 commit fd23a5e
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@
@Order(Ordered.HIGHEST_PRECEDENCE)
public class CustomerCorsFilter implements Filter {
private final List<String> allowedOrigins = Arrays.asList(
DOMAIN_URL,"프론트 ip 넣는 곳"
DOMAIN_URL,"*"
);

@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;

String origin = request.getHeader("Origin");
if (allowedOrigins.contains(origin)) {
response.setHeader("Access-Control-Allow-Origin", origin);
}
// String origin = request.getHeader("Origin");
// if (allowedOrigins.contains(origin)) {
response.setHeader("Access-Control-Allow-Origin", "*");
// }
// CORS 허용한 Origin
response.setHeader("Access-Control-Allow-Credentials", "true");
// 자격이 포함된 요청 받기
Expand Down

0 comments on commit fd23a5e

Please sign in to comment.