P
P
Pavel Zhukau2015-09-10 13:29:42
Apache HTTP Server
Pavel Zhukau, 2015-09-10 13:29:42

How to remove No 'Access-Control-Allow-Origin' header is present on the requested resource error?

Good afternoon. Faced a problem. There is an api on laravel, I'm trying to get data through angular, to which I get in response:

XMLHttpRequest cannot load http://backend/api No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://frontend' is therefore not allowed access.

I can transfer from local to working servers, under backend and frontend there will be different servers on the same subnet. In production, I need the backend to be able to give information only to my frontend, but in the development process to everyone. Thanks in advance for your reply. I saw about crocs, but I tried to screw in laravel on return response->json($data)->header() and pass crocs headers in the header, but all to no avail.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vyacheslav, 2015-09-10
@NikesDark

To the response from the server, you need to add the header Access-Control-Allow-Origin: '*' - to allow cross-domain requests for any addresses, or Access-Control-Allow-Origin: ' http://client-domain ' - for the elite.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question