How to define CORS in Websphere Application Server Liberty Profile V8.5

前端 未结 4 1217
遥遥无期
遥遥无期 2021-02-02 00:18

Is it possible to apply cross-origin resource sharing (CORS) in a Websphere Application Server Liberty Profile V8.5 ?

I searched the redbook but couldn\'t find IBM menti

4条回答
  •  旧时难觅i
    2021-02-02 00:46

    For those who is looking for a workaround while using IBM Websphere Application Server and looking for an answer to apply CORS. (You should do this programmatically ) I know the op is looking for an answer without using java code or else... This might be helpfull to somebody else.. Write a filter that lets you to set response headers programmatically. Such as :

    public class YourFilter implements javax.servlet.Filter{
    
        @Override
        public void doFilter(ServletRequest request,ServletResponse servletResponse , FilterChain chain) throws IOException, ServletException {
            HttpServletResponse response = (HttpServletResponse ) servletResponse ;
            response.setHeader("Access-Control-Allow-Origin", "*");
            response.setHeader("Access-Control-Allow-Headers","Access-Control-Allow-Origin, X-Requested-With", bla,bla...);
        }
    }
    

提交回复
热议问题