[solved] Error: No 'Access-Control-Allow-Origin' header

My Code

this.itemlist = HTTP.call('GET', 'http://localhost:8000/unit.json.do',function(er,result){});

Failed to load http://localhost:8000/unit.json.do: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:3000’ is therefore not allowed access.

What kind of server is running on port 8000?
If you want to talk to it from the client, that server will need Access-Control-Allow-Origin headers set to allow you to access it

Alternatively, you can fetch the url from your server, which will happily ignore the absence of Access-Control-Allow-Origin headers

By setting Access-Control-Allow-Origin: * in response header at your server side, will solve the CORS issue.
(Here * means all type of domain, you can specified your own also)

Actually , CORS provides a mechanism for servers to tell the browser it is OK for requesting domain A to read data coming from domain B. It is done by including a new Access-Control-Allow-Origin HTTP header in the response. When a browser receives a response from a Cross-Origin source, it will check for CORS headers. If the origin specified in the response header matches the current origin, it allows read access to the response. Otherwise, you get the nasty error message, as you are getting.

1 Like

Thanks all now I fixed by reconfigure on Laravel.