2
votes

Help!!!!!!!!!! I am stuck by the annoying cross domain issue. Domain A wants to post to domain B.

$http_({
    'method': 'POST',
    'url':'https://domainB.com/api/v5.php?rpc=/items/get',
    'data': {'businessId': 1}
})

But the request is always failing. I keep getting the same thing.

Name:v5.php?rpc=/items/get
domainB.com/api/
Method:OPTIONS; 
Status:(canceled);

Request URL:https://domainB.com/api/v5.php?rpc=/items/get
Request Headers CAUTION: Provisional headers are shown.
Access-Control-Request-Headers:accept, content-type
Access-Control-Request-Method:POST 
Origin:http://domainA.com
Referer:http://domainA.com/html/dashboard.html
Query String Parametersview sourceview URL encoded
rpc:/items/get  

The server side configuration:

Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "Accept, Origin, X-Requested-With, Content-Type"
Header add Access-Control-Allow-Methods "GET,POST,OPTIONS"
Header set Access-Control-Allow-Credentials "true"
I also try to force the Content-Type to be text/plain, but still cannot work. Do I need to do some additional processing on the backend? Help me! Thanks.
1

1 Answers

2
votes

When setting headerAccess-Control-Allow-Credentials to true, you cannot use a wildcard for header Access-Control-Allow-Origin. That is, a specific host must be specified

Duplicated issue: Cross-domain AJAX withCredentials, PHP returns header content-lenght, but no content