#Java spring response header

5 messages · Page 1 of 1 (latest)

manic nebula
#

How can I set response header? I am getting this error The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'.

    public void doFilter(ServletRequest req, ServletResponse res,
                         FilterChain chain) throws IOException, ServletException {

        HttpServletResponse response = (HttpServletResponse) res;

        response.setHeader(
                "Access-Control-Allow-Origin", "http://localhost:3000/");
        response.setHeader(
                "Access-Control-Allow-Credentials", "true");
        chain.doFilter(req, response);
    }```
arctic crystalBOT
#

This post has been reserved for your question.

Hey @manic nebula! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

old flame
#

that should work

#

have you added filter in filter chain?