Page 1 of 1

Access-Control-Allow-Origin

Posted: Sat Jul 21, 2018 11:29 am
by bluehouse
Hello,
i have booking page and i am using Angularjs to access the api everything is working perfectly except the following error so how can i solve this "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://www.beds24.com/api/json/getAvailabilities. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing"

Regards,

Re: Access-Control-Allow-Origin

Posted: Sat Jul 21, 2018 3:53 pm
by markkinchin
You should be using https://api.beds24.com/json/getAvailabilities

There is a Access-Control-Allow-Origin: * header in the JSON response from that endpoint.

Re: Access-Control-Allow-Origin

Posted: Mon Jul 23, 2018 12:21 pm
by bluehouse
still it is the same here is the output do you i have to use any other options(i am using this code right now $http.post('https://api.beds24.com/json/getAvailabilities', $scope.bookingdatas).then(function (data, status, headers, config) {
alert("success");
console.log(data);

},function (data, status, headers, config) {
alert("error");
});
)
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.beds24.com/json/getAvailabilities. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.beds24.com/json/getAvailabilities. (Reason: CORS request did not succeed).

Re: Access-Control-Allow-Origin

Posted: Mon Jul 23, 2018 1:42 pm
by markkinchin
Can you provide a link to your page with this script so I can test it?

Re: Access-Control-Allow-Origin

Posted: Mon Jul 23, 2018 7:40 pm
by bluehouse
Sorry it is not published yet i am working locally, but it works perfectly if i user CORS (cross origin resource sharing) in my browse

Re: Access-Control-Allow-Origin

Posted: Tue Jul 24, 2018 7:25 am
by markkinchin
The following header is in the response, what more do you need?

Access-Control-Allow-Origin *

Re: Access-Control-Allow-Origin

Posted: Tue Jul 24, 2018 11:09 am
by bluehouse
That is all i need but still it requires me to allow CORS do you have any sample javascript or Angularjs application which works correctly to see.

Re: Access-Control-Allow-Origin

Posted: Tue Jul 24, 2018 4:29 pm
by markkinchin
bluehouse wrote:
Tue Jul 24, 2018 11:09 am
That is all i need but still it requires me to allow CORS do you have any sample javascript or Angularjs application which works correctly to see.
Google is your friend :)

Re: Access-Control-Allow-Origin

Posted: Sat Aug 11, 2018 2:19 am
by innexpress
$.ajax({

url: "crossdomainurl/somepage...."
type: "POST",
crossDomain: true,
"headers": {
"accept": "application/json",
"Access-Control-Allow-Origin":"*"
},
success: function(data){
// process data here
},
error: function (xhr, status) {
alert("error");
}
});