Just starting out? Need help? Post your questions and find answers here.
karu
Posts: 40 Joined: Mon Feb 24, 2014 10:16 pm
Post
by karu » Tue Oct 24, 2017 6:38 am
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
SparrowhawkMMU
Posts: 291 Joined: Wed Aug 19, 2015 3:02 pm
Location: United Kingdom
Post
by SparrowhawkMMU » Tue Oct 24, 2017 8:18 am
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
Post
by karu » Tue Oct 24, 2017 10:06 am
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
Post
by karu » Tue Oct 24, 2017 11:06 am
Now i succeed, thanks:
<?php
header("Access-Control-Allow-Origin: *");
?>
text to return