javascript - Cors issue when rest api application server(express) and Angulars js application running on different port -
i have rest api application written in node.js & express running on port 3000 , angularjs application running on port 9001 on same server . on calling rst api angularjs application giving cors issue .
in rest api application , have used "cors" module
var cors = require('cors'); app.use(cors());
but giving me following error
cross-origin request blocked: same origin policy disallows reading remote resource @ http://localhost:3000/api/user/login. can fixed moving resource same domain or enabling cors
request header , response header follow
response 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
thanks
i solved adding adding line app.options('*', cors()); before routes.
it issue of preflight request http-request-header "options"
Comments
Post a Comment