Answer the question
In order to leave comments, you need to log in
How to make a CORS request to another domain using PHP CURL?
The point is this.
There is a server with basic authorization. There is an example of accessing data using a jQuery login-password. It perfectly fulfills, logs in, receives data.
But, when I try to do the same in PHP, I get a whack. Browser research showed that AJAX generates two requests (which is, in general, normal for a cross-domain option).
Apparently, without an OPTIONS request, I get a whack, although I try to insert the necessary headers into the POST request
POST /login HTTP/1.1
Authorization: Basic ааааааааааа==
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36
Host: needserver.com
Accept: */*
Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate, br
Referer: http://myserver.ru
Content-Type: application/json; charset=utf-8
Content-Length: 49
Connection: keep-alive
X-Compress: 1
Access-Control-Allow-Origin: *
origin: http://myserver.ru
Answer the question
In order to leave comments, you need to log in
The issue can be considered closed. The problem is not options.
answer to question
the OPTIONS request goes through fine, but the authorization still fails. I will search further
curl doesn't "respect" cors. This is a browser-only limitation.
curl debug? What does it give?
curl_error?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question