I added the filter but the wildcard gave problems with session state and had to change the filter not just be wildcard but origin of requester On Apr 11, 2016 6:30 PM, "Ben Fortuna" <[email protected]> wrote:
> I have implemented this before in AEM, we added the configuration to the > Apache/Dispatcher in front of AEM, which may be the simplest approach if > you are using Apache also. > > Regards, > Ben > On 12 Apr 2016 8:13 am, "Frank Langel" <[email protected]> wrote: > > Hi, > > Created filter service, which works fine, but isn’t there an easier > (configuration) option ? > > Thanks > Frank > > > > import java.io.IOException; > > > > import javax.servlet.Filter; > > import javax.servlet.FilterChain; > > import javax.servlet.FilterConfig; > > import javax.servlet.ServletException; > > import javax.servlet.ServletRequest; > > import javax.servlet.ServletResponse; > > import javax.servlet.http.HttpServletResponse; > > > > import org.osgi.service.component.annotations.Component; > > > > @Component(immediate=true,property={"pattern=/.*"}) > > public class CustomFilter implements Filter { > > > > @Override > > public void destroy() { > > // TODO Auto-generated method stub > > } > > > > @Override > > public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain > chain) > > throws IOException, ServletException { > > > > System.out.println("Filtering"); > > > > HttpServletResponse res = (HttpServletResponse) arg1; > > > > res.addHeader("Access-Control-Allow-Origin","*"); > > res.addHeader("Access-Control-Allow-Methods","GET,POST"); > > res.addHeader("Access-Control-Allow-Headers","Origin, X-Requested-With, > Content-Type, Accept"); > > > > chain.doFilter(arg0,arg1); > > } > > > > @Override > > public void init(FilterConfig arg0) throws ServletException { > > } > > > > } > > > > From: Frank Langel > Date: Monday, April 11, 2016 at 5:20 PM > To: "[email protected]" > Subject: CORS configuration in HTTP Service > > Hi team, > > I like to configure CORS (Cross Origin Requests) by always returning the > following http parameter > > Access-Control-Allow-Origin: * > > in the response. One option is to write a http filter server that adds the > parameter, but this is quite a bit of work for adding a simple parameter. > Jetty supports that kind of configuration in web.xml but I think web.xml is > not working under Felix http. > > Any easy way to add a http parameter to each response of each http server? > Thanks > Frank >

