node. JS Express cross-domain problem solved this problem, that's really cool!
Cross-domain problem mainly in the header of the first to provide a world-class header definition http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html and then provide a netizen to provide a detailed header Http://kb.cnblogs.com/page/92320/these two help to understand the type and function of the header, but unfortunately the cross-domain related two header properties I have not found the relevant definition, the following directly tell you 1 is access-control-allow-origin allowed domain 2 is the header type allowed by access-control-allow-headers
The first item can be set directly to * denotes any but the second item cannot be written like this, testing cross-domain discovery error in chrome, the final code looks like this:
function (req, res, next) { Res.header ("Access-control-allow-origin", "*"); Res.header ("Access-control-allow-headers", "Content-type,content-length, Authorization, Accept, X-requested-with "); Res.header ("Access-control-allow-methods", "put,post,get,delete,options"); Res.header ("x-powered-by", ' 3.2.1 ') if(req.method== "Options") res.send (200); /* get the options request back quickly */ Else Next ();});
node. JS Express cross-domain issues