I have a leisure api application written in node.js, and express runs on port 3000 and an angularjs application running on port 9001 on the same server. When rst api is called from an angularjs application, it gives a cors problem.
In the rest api application, I used the "cors" module
var cors = require('cors');
app.use(cors());
But it gives me the following error
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http:
The header of the request and response header is as follows:
Answer Header
Content-Length 222
Content-Type application/json; charset=utf-8
Date Tue, 16 Dec 2014 08:40:05 GMT
X-Powered-By Express
view source
Request header
Accept application/json, text/plain, /
Accept-Encoding gzip, deflate
Accept-Language en-US,en;q=0.5
Authorization null
Content-Length 47
Content-Type application/json;charset=utf-8
Host localhost:3000
Origin http://localhost:9001
Referer http://localhost:9001/
User-Agent Mozilla/5.0 (Windows NT 6.2; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0
thank
source
share