2

i have a problem with the SOP. I want to develop a Web-Based-Application witch HTML, JS etc. this App have to run on localhost. I don't want to have a webserver. I have a device in the LAN, which I can't edit or something. On this device is a https rest service. Therefrom i want to get data.

If I want access to the rest service the browser throws an error, which says I cant access to this site because of the SOP.

var xmlHttp = createRequest();
xmlHttp.open("GET", url, false);
xmlHttp.send();
return xmlHttp.responseText;

Thats my code. I hope you can help me.

1 Answers1

0

In short, it seems you can't place requests on servers other than the one from which the page was served unless the server explicitly permits it. This page explains how clients should place such requests, and this one covers how servers should respond.

bbsimonbb
  • 27,056
  • 15
  • 80
  • 110
  • I get this error: http://fs5.directupload.net/images/160307/qs3pvkpu.png it's german but i think you can see what i mean – dschoeneborn Mar 07 '16 at 10:10
  • @D.Schöneborn — It says, if I'm translating it correctly, that the response doesn't have an Access-Control-Allow-Origin header on it … so add an Access-Control-Allow-Origin header to the response. Google will help you find the correct syntax. – Quentin Mar 07 '16 at 10:21
  • Ok I'm going to have to change my answer ! In short, it seems you can't place requests on servers other than the one from which the page was served *unless* the server explicitly permits it. The mozilla pages that explain this are [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS) and [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Server-Side_Access_Control) – bbsimonbb Mar 07 '16 at 10:29