SB and HTTPRequest

Just starting out? Need help? Post your questions and find answers here.
karu
Posts: 40
Joined: Mon Feb 24, 2014 10:16 pm

SB and HTTPRequest

Post by karu »

How you guys solved HTTPRequest in development time. In development time i push run button on SB toolbar and code will be run on 127.0.0.1:9080. In this case i cant use HTTPRequest, because other address that 127.0.0.1:9080 will be cross domain and 127.0.0.1:9080 used by SB server? I need to communicate with php script.
Sorry, if my english is not clear enouhgt :)
User avatar
SparrowhawkMMU
Posts: 281
Joined: Wed Aug 19, 2015 3:02 pm
Location: United Kingdom

Re: SB and HTTPRequest

Post by SparrowhawkMMU »

Hi Karu,

At the server end, you need to send an allow origin header. for example, in PHP, you need to include this with your response:

Code: Select all

header('Access-Control-Allow-Origin: *');
The * means any origin, ie any client anywhere - you can filter it to specific IP addresses if these are known and fixed.

Further reading: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
karu
Posts: 40
Joined: Mon Feb 24, 2014 10:16 pm

Re: SB and HTTPRequest

Post by karu »

SparrowhawkMMU wrote:Hi Karu,

At the server end, you need to send an allow origin header. for example, in PHP, you need to include this with your response:

Code: Select all

header('Access-Control-Allow-Origin: *');
The * means any origin, ie any client anywhere - you can filter it to specific IP addresses if these are known and fixed.

Further reading: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
thanks but somehow i didnt understand, can you give me example please, thanks
karu
Posts: 40
Joined: Mon Feb 24, 2014 10:16 pm

Re: SB and HTTPRequest

Post by karu »

Now i succeed, thanks:
<?php
header("Access-Control-Allow-Origin: *");
?>

text to return
Post Reply