javascript - front-end cross-domain issues
三叔
三叔 2017-06-14 10:53:50
0
2
718

If the backend interface is set to restrict domain name access, can I request data by pretending to be the other party's domain name or IP through node or ajax?

三叔
三叔

reply all(2)
左手右手慢动作

You can configure a reverse proxy through niginx to solve cross-domain problems

曾经蜡笔没有小新

In this case, ajax’s jsonp will not work. You can forward it through node middleware

middleware: [ // 请求代理,按需设置
            proxy('/api', {
                target: 'http://op.juhe.cn', // 目标地址
                changeOrigin: true,
                ws: true, //websocket
                pathRewrite: {
                    '^/api': '' //重写地址
                }
            })
        ]
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!