By tvongeldern
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!
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: *”);
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.