Access-Control-Allow-Origin

Develper issues when using the Beds24 APi.
Post Reply
bluehouse
Posts: 4
Joined: Sat Feb 22, 2014 6:05 pm

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,
markkinchin
Site Admin
Posts: 935
Joined: Fri Mar 02, 2012 1:43 pm

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.
bluehouse
Posts: 4
Joined: Sat Feb 22, 2014 6:05 pm

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).
markkinchin
Site Admin
Posts: 935
Joined: Fri Mar 02, 2012 1:43 pm

Can you provide a link to your page with this script so I can test it?
bluehouse
Posts: 4
Joined: Sat Feb 22, 2014 6:05 pm

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
markkinchin
Site Admin
Posts: 935
Joined: Fri Mar 02, 2012 1:43 pm

The following header is in the response, what more do you need?

Access-Control-Allow-Origin *
bluehouse
Posts: 4
Joined: Sat Feb 22, 2014 6:05 pm

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.
markkinchin
Site Admin
Posts: 935
Joined: Fri Mar 02, 2012 1:43 pm

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 :)
innexpress
Posts: 14
Joined: Thu Feb 09, 2017 3:38 am

$.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");
}
});
Post Reply