指尖下的技术 2023-07-20 18:10 采纳率: 33.3%
浏览 43

关于跨域配置,如何解决?

我的跨域配置是这样的,请求后台的时候应该访问的是8080端口,不知道为什么还是8083端口,有没有哪位大师知道是什么情况呢


module.exports = {
    devServer: {
        host: 'localhost',
        port: '8083',
        // 配置要访问的后台地址
        proxy: {
            '/api': {   // 用 /api 来代替下面 target 中的地址
                target: `http://127.0.0.1:8080`,    // 后台地址(不要忘了写前面的http)
                changOrigin: true,//允许跨域
                ws:true,
                pathRewrite:{
                    '^/api': ''
                }
            }
        }
    }
}

![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/524937748986126.png "#left")

img

  • 写回答

3条回答 默认 最新

  • 简效 2023-07-20 18:16
    关注

    你的请求地址应该是这样才对,/api/getCode,试一下

    评论

报告相同问题?

问题事件

  • 创建了问题 7月20日