automatically add header to every response

后端 未结 6 1122
抹茶落季
抹茶落季 2020-11-28 07:43

I want to add this header \"Access-Control-Allow-Origin\", \"*\" to every response made to the client whenever a request has made for rest controllers in my application to a

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-28 07:59

    I am also face this issue and i have add this code issue fixed.

    public static HttpServletResponse getResponse(HttpServletResponse response) {
        response.setHeader("Access-Control-Allow-Origin", "*");
        response.setCharacterEncoding("UTF-8");
        response.setHeader("Access-Control-Allow-Methods", "POST, GET");
        response.setHeader("Access-Control-Allow-Headers", "x-requested-with");
        return response;
    }
    

提交回复
热议问题