2014년 12월 2일 화요일

Node server doesn't load external resources

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 loadhttp://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



> 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 loadhttp://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


댓글 없음:

댓글 쓰기