vue运行项目请求axios根地址爆出错误。我的登录页面可以进去,但是输入账号密码后,点击登录按钮,但是没有反应。
Failed to load resource: net::ERR_CONNECTION_REFUSED
Uncaught (in promise) Error: Network Error
at createError (createError.js:16:1)
at XMLHttpRequest.handleError (xhr.js:117:1)
我尝试修改我的服务器地址和前端请求根路径。但是之后爆出404。这个问题困扰了我两天。下面附上我的端口截图
前端挂载请求根路径
Vue.prototype.$http = axios
// 设置请求的根路径
axios.defaults.baseURL = "http://localhost:8081"
Vue.config.productionTip = false
这是后端服务器端口
server:
port: 8081
这是后端跨域请求
registry.addMapping("/**")
// .allowedOrigins("*","null")
.allowedOrigins("Http://localhost:8081","null")
.allowedMethods("Get","POST","PUT","OPTIONS","DELETE")
.allowCredentials(true)
.maxAge(3600);
我看你的后端配置
你先修改一下
可以先尝试将allowedOrigins修改成*通配符进行测试,看是否与上述两点存在影响