Access-Control-Allow-Origin

Post Reply
bluehouse
Posts: 4
Joined: Sat Feb 22, 2014 6:05 pm

Access-Control-Allow-Origin

Post by bluehouse » Sat Jul 21, 2018 11:29 am

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: 885
Joined: Fri Mar 02, 2012 1:43 pm

Re: Access-Control-Allow-Origin

Post by markkinchin » Sat Jul 21, 2018 3:53 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

Re: Access-Control-Allow-Origin

Post by bluehouse » Mon Jul 23, 2018 12:21 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: 885
Joined: Fri Mar 02, 2012 1:43 pm

Re: Access-Control-Allow-Origin

Post by markkinchin » Mon Jul 23, 2018 1:42 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

Re: Access-Control-Allow-Origin

Post by bluehouse » Mon Jul 23, 2018 7:40 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: 885
Joined: Fri Mar 02, 2012 1:43 pm

Re: Access-Control-Allow-Origin

Post by markkinchin » Tue Jul 24, 2018 7:25 am

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

Re: Access-Control-Allow-Origin

Post by bluehouse » 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.

markkinchin
Site Admin
Posts: 885
Joined: Fri Mar 02, 2012 1:43 pm

Re: Access-Control-Allow-Origin

Post by markkinchin » Tue Jul 24, 2018 4:29 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

Re: Access-Control-Allow-Origin

Post by innexpress » Sat Aug 11, 2018 2:19 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