Cross domain issue Access-Control-Allow-Origin - Stack Overflow
PHP中文网
PHP中文网 2017-05-19 10:20:18
0
5
764

I have processed the header here, why is there still a cross-domain problem

PHP中文网
PHP中文网

认证0级讲师

reply all(5)
Ty80

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跨域 请参考

PHPzhong

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);
                    }
                });
            },
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!