No Access-Control-Allow-Origin header is present on the requested resource

前端 未结 4 1301
感情败类
感情败类 2020-12-05 05:08

I want to access information from same domain but with different port number, To allow this I am adding Access-Control-Allow-Origin with the response header.

4条回答
  •  感动是毒
    2020-12-05 05:51

    Solution:
    Instead of using setHeader method I have used addHeader.

    response.addHeader("Access-Control-Allow-Origin", "*");
    

    * in above line will allow access to all domains, For allowing access to specific domain only:

    response.addHeader("Access-Control-Allow-Origin", "http://www.example.com");
    

    For issues related to IE<=9, Please see here.

提交回复
热议问题