D
D
Dvorak2016-08-30 17:48:00
Denver
Dvorak, 2016-08-30 17:48:00

How to fix a cross-domain request?

I'm trying to make a cross domain request. In the console I see the following: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' localhost ' is therefore not allowed access.

at the same time, when writing AJAX parameters, crossDomain:true is indicated
How to fix it?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
D
Denis Ineshin, 2016-08-30
@IonDen

It is not that simple. A cross-domain request is not just like that, they added one parameter and everything worked, alas, the security rules directly prohibit this.
For such a request to work, you need to have permission from that side. Learning CORS .
There is another easier option, jsonP requests . But again, there must be some kind of support from the server.

E
evnuh, 2016-08-30
@evnuh

no way

A
Andrey Zubkov, 2016-08-30
@zubkov_work

Make a request to your backend, which will forward the request to another domain and send it back to you.

L
LittleFatNinja, 2016-08-30
@LittleFatNinja

a request to yourself, and there, through curl, the request to the right place

X
xmoonlight, 2016-08-30
@xmoonlight

You need to look at what is written in the response header from the server in the field: Access-Control-Allow-Origin
and grant access to the localhost domain if the requested resource is yours.
Otherwise, on the client side without the consent of the requested resource, there is no way to do this and you will have to use cURL (or a similar mechanism) on the server side.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question