HTML5 and Mobile Web: cross-domain issues

problem

In good local tests, put on the server unable to get data there is a problem, all the logs are read, not a little problem, but very strange, and then I opened up Google console.

Error message:

question.html:1 Access to XMLHttpRequest at 'http://120.27.144.13:8080/news/getNews.do' from origin 'http://127.0.0.1:8848' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

it means:

Another resource server requests a different port, for security reasons, the browser restrictions initiated cross-source HTTP request, and abnormal phenomenon beginning of this article appears.

Solution:

My background is SpringMVC, add the following comments.

@CrossOrigin(origins = "*")

 

 

 

 

 

Published 349 original articles · won praise 161 · views 190 000 +

Guess you like

Origin blog.csdn.net/qq_42192693/article/details/103332746