I have this syntax:
var url = new Http(“http://www.stuff.com/rcbattledumps/battleDataReceiver.php?dump=test”);
with this php file receiving it:
$dump = $_REQUEST['dump'];
$myfile = file_get_contents('battledumps.txt')
$myfile = $myfile."\n**************************\n".$dump;
which uses this .htaccess file:
Header add Access-Control-Allow-Origin “*”
Header add Access-Control-Allow-Credentials “true”
Header add Access-Control-Allow-Headers “origin, x-requested-with, content-type”
Header add Access-Control-Allow-Methods “PUT, GET, POST, DELETE, OPTIONS”
Yet every single time, I get Error 500. Am I doing something obviously wrong? I know the website isn’t down since I’m connecting to it as I test. I’m not a web developer by any means, I’m just trying to hack something together to output data from a certain mini game in my project so the designers can see the output and see if the logic is behaving the way they intended. (Before everyone piles on and tells me how insecure this all is, it’s a temporary setup for internal testing only)
What happens if you go to the url in a web browser?
Okay, it turns out I did have a dumb typo in the PHP (gotta love silent errors), but when I fixed that and replaced “test” with my real data dump, I’m getting this error which I had been getting earlier in my trials:
"XMLHttpRequest cannot load http://www.stuff.com/rcbattledumps/battleDataReceiver.php?dump=NE…20*****%20%20END%20SKIRMISH%20%20*****%20*****%202018-04-18%2010%3A56%3A47. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:9000’ is therefore not allowed access.
I basically changed “dump=test” to “dump=”+StringTools.urlEncode(_dataString)); I don’t get it, since clearly I have an .htaccess file granting wide open permissions. Is the Haxe code adding some kind of default header somewhere?
Okay, figured it out workaround, at the very least. I had to say url.request(true), thus sending via POST, for that .htaccess file to recognize me as having permission to submit it, and now it works. I do wonder why I needed that, as I enabled a number of different methods in the above .htaccess file. What is the default for haxe.Http if post is set to false?