Aurelia AdminPanel served inside Express-App - Cors Error on Droplet?

October 15, 2016 1.7k views
Node.js MEAN Deployment Ubuntu 16.04

Jolly good day guys!

I’m trying to get a Project to work that contains of 1.) An Express application that Serves all FIles to the visitor, and 2.) An Aurelia Admin-Panel that allows changes to the database over api/fetch-calls to the express application.
The Aurelia-Adminpanel is serverd via the public/static files of the express-application.

On my Local Machine this combination works great, cause this way there are no cors-problems, since the Admin-App is serverd over the express-app.

On my dropled i get an error though:
“Fetch API cannot load http://localhost:3030/casino. Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ’http://188.166.161.73:3030’ is therefore not allowed access.”

Which looks like a cors problem, right? Thats the exact same error I get when I start the adminpanel-index not over my express app via routes, but execute it directly from my finder.

http://localhost:3030/admin <– Works on my localmachine
http://188.166.IPIP.73:3030/admin <– Error, See above

The Aurelia/Admin pannel is requesting “http://localhost:3030/**path**

Is there anything I’m missing out? Is there a way to get the desired behaviour?

Thanks a lot!

1 Answer

I just realized, that the IP sending requests to the Express-App is always the Machines IP where the Aurelia-App is loaded from - regardless of where it is hosted. Is that correct?

Have another answer? Share your knowledge.

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