Report this

What is the reason for this report?

Connecting Droplet to my front end

Posted on July 23, 2015

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:

request.open(“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?



This textbox defaults to using Markdown to format your 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: *”);

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.