Connecting Droplet to my front end

Posted July 23, 2015 2.7k views
PHPFAQLAMP StackDigitalOcean

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);

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?

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.

Submit an Answer
1 answer

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: *”);