原生跨域 var http=require('http'); var server = http.createServer(function (req,res) { res.setHeader('Access-Control-Allow-Origin', req.headers.origin) res.end("success") }); server.listen(1200); console.log('listen on 1200'); express跨域 const expres…
XMLHttpRequest cannot load http://localhost:3000/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. 上面是我学习nodejs中碰到的一个异常,下面有代码以及解决方案. 1)js文件代码 var http=require('http');var qu…