vue-cli3项目运行时一直发http://localhost:8080/sockjs-node/info?t=xxxxxxxxxxxxxxxxxx请求
解决方法:
在vue.config.js中配置
// vue.config.js
module.exports = {
devServer: {
compress: true,
host: 'localhost',
port: 8080,
proxy: {
//解决访问外部接口跨域问题
'/proxy/': {
'target': 'https://www.tianqiapi.com', //天气接口地址
'secure': false, // false为http访问,true为https访问
'changeOrigin': true, // 跨域访问设置,true代表跨域
'pathRewrite': { // 路径改写规则
'^/proxy': '' // 以/proxy/为开头的改写为''
}
}
}
}
}
用于自己记录学习的,不能解决可以多查看别的方式