From f37dbb382c572115b531256e1929bbc66b3c0030 Mon Sep 17 00:00:00 2001 From: "DCHQ, Inc" Date: Thu, 7 Jan 2016 23:08:23 -0800 Subject: [PATCH] Create CORSFilter.java New Consolidated UI added by DCHQ --- .../banking/web/util/CORSFilter.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 java-spring/common-web/src/main/java/net/chrisrichardson/eventstore/javaexamples/banking/web/util/CORSFilter.java diff --git a/java-spring/common-web/src/main/java/net/chrisrichardson/eventstore/javaexamples/banking/web/util/CORSFilter.java b/java-spring/common-web/src/main/java/net/chrisrichardson/eventstore/javaexamples/banking/web/util/CORSFilter.java new file mode 100644 index 0000000..5568e8b --- /dev/null +++ b/java-spring/common-web/src/main/java/net/chrisrichardson/eventstore/javaexamples/banking/web/util/CORSFilter.java @@ -0,0 +1,25 @@ +package net.chrisrichardson.eventstore.javaexamples.banking.web.util; + +import org.springframework.stereotype.Component; +import org.springframework.web.filter.OncePerRequestFilter; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * @since 12/25/2015 + */ +@Component +public class CORSFilter extends OncePerRequestFilter { + + @Override + protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { + response.addHeader("Access-Control-Allow-Origin", "*"); + response.addHeader("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, Origin, Authorization, Accept, Client-Security-Token, Accept-Encoding"); + response.addHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, PUT"); + filterChain.doFilter(request, response); + } +}