I have processed the header here, why is there still a cross-domain problem
认证0级讲师
I can’t see the picture clearly. Is this written in nodejs?
res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Headers", "X-Requested-With"); res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS"); res.header("X-Powered-By",' 3.2.1') res.header("Content-Type", "application/json;charset=utf-8");
node跨域 请参考
Are you using express framework? This is how my express framework program works:
app.all('*', function(req, res, next) { res.append('Access-Control-Allow-Origin', '*'); next() });
You need to process all requests in a unified manner and set the res header to allow cross-domain requests. I don’t know how to write your code specifically. If you still can’t solve it, I suggest you post the code and take a look.
Just use jsonp to cross domain
getJSONDATA(){ $.ajax({ url: "xxx", //接口地址 data: {xxx}, //传参 dataType: "jsonp", jsonpCallback: "person", //核心cb success: function (data) { console.log(data.s); } }); },
I can’t see the picture clearly. Is this written in nodejs?
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
res.header("X-Powered-By",' 3.2.1')
res.header("Content-Type", "application/json;charset=utf-8");
node跨域 请参考
Are you using express framework? This is how my express framework program works:
You need to process all requests in a unified manner and set the res header to allow cross-domain requests. I don’t know how to write your code specifically. If you still can’t solve it, I suggest you post the code and take a look.
Just use jsonp to cross domain