Node server doesn't load external resources

31 views
Skip to first unread message

Mountain

unread,
Nov 30, 2014, 7:53:02 AM11/30/14
to nod...@googlegroups.com
Yesterday I tried to use a little node.js script as localhost in my website development workflow.

It works fine but no external resources are shown - my browser gives me the following error message: "XMLHttpRequest cannot load http://xxx.xxx/xxx/wallpaper_01.jpg. Origin http://localhost:3000 is not allowed by Access-Control-Allow-Origin."

I don't know node.js at all. How do I have to change the script to get it work?

var connect = require('connect');
var serveStatic = require('serve-static');
var app = connect();


app
.use(serveStatic("./_distribution"));
app
.listen(3000);



Thanks a lot

Ryan Schmidt

unread,
Dec 1, 2014, 10:10:59 AM12/1/14
to nod...@googlegroups.com

On Nov 30, 2014, at 6:53 AM, Mountain wrote:

> Yesterday I tried to use a little node.js script as localhost in my website development workflow.
>
> It works fine but no external resources are shown - my browser gives me the following error message: "XMLHttpRequest cannot load http://xxx.xxx/xxx/wallpaper_01.jpg. Origin http://localhost:3000 is not allowed by Access-Control-Allow-Origin."
>
> I don't know node.js at all. How do I have to change the script to get it work?

Your question is not about node; it's about how web browsers and web servers work. Please read:

https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS


Reply all
Reply to author
Forward
0 new messages