search

Home  >  Q&A  >  body text

javascript - front-end cross-domain issues

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?

三叔三叔2729 days ago761

reply all(2)I'll reply

  • ringa_lee

    ringa_lee2017-06-14 10:55:50

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

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-06-14 10:55:50

    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': '' //重写地址
                    }
                })
            ]

    reply
    0
  • Cancelreply