Connecting Droplet to my front end

So my front end is hosted by AWS, just a simple s3 bucket with HTML, CSS, and JavaScript files on there.

The JavaScript files on my front end make XMLHttpRequests, how should I word those to reach out to my droplet? Say my URL is 55.55.555.555 and the file I need is file5.php.

here is what I have been using:“POST”,“http://55.55.555.555/file5.php”,true); request.setRequestHeader(“Content-type”,“application/x-www-form-urlencoded”);

It is not working, I get this feedback:

XMLHttpRequest cannot load http://55.55.555.555/file5.php. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘null’ is therefore not allowed access. The response had HTTP status code 404.

Anybody know what I should be doing differently?


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

You need to set an Origin allow rule in the headers of your application. in the file file5.php you can add this

header(“Access-Control-Allow-Origin: *”);