URLRequest post request HTML5 problem

I have a simple POST request, which is working as expected on all platforms except HTML5.
In HTML5, my game sends GET request somehow, any idea why could it happen?

Here is my code:

_req = new URLRequest(url);
_req.data = vars;
_req.method = URLRequestMethod.POST;
_onReq = onReq;
_loader.dataFormat = URLLoaderDataFormat.TEXT;

I just tried this code in a sample project:


import openfl.display.Sprite;
import openfl.net.*;

class Main extends Sprite {
	public function new () {
		super ();
		var vars = new URLVariables ();
		vars.hello = 100;
		var _req = new URLRequest("./assets/foo");
		_req.data = vars;
		_req.method = URLRequestMethod.POST;
		//_onReq = onReq;
		var _loader = new URLLoader ();
		_loader.dataFormat = URLLoaderDataFormat.TEXT;

Opening the HTTP debugger, and checking the Network tab (after a refresh), showed the following:

Request URL:
Request Method:POST
Status Code:405 Method Not Allowed
Remote Address:
Referrer Policy:no-referrer-when-downgrade

So the address I requested was bad, but looks like it is sending the request as POST properly

Ok, I’ll check with simple project, but my server reporting GET requests from HTML5… :frowning:
Thank you!

Ok, I’ve checked in browser’s dev tools and I get a different results.
Here is request from Flash version:

And here is HTML5:

UPDATE: Problem occurs when you send request to actual url.
In your example, “./assets/foo” works fine for me too, I see POST request, but changing it to real url makes it OPTIONS. :hushed:

Ah, looks like its part of CORS:

Yeah, it helped!
Thanks a lot! :slight_smile: