Access to XMLHttpRequest at ‘http://localhost:xxxx“

在开发过程中,遇到了Vue.js应用进行跨域请求时出现的错误,具体表现为'Access-Control-Allow-Origin'头缺失导致的CORS政策阻止。解决方法是对目标项目进行配置,以允许跨域请求,从而成功解决此问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 报错信息如下

进行跨域请求时报错,报错信息如下:

Download the Vue Devtools extension for a better development experience:
https://github.com/vuejs/vue-devtools
vue.js:9064 You are running Vue in development mode.
Make sure to turn on production mode when deploying for production.
See more tips at https://vuejs.org/guide/deployment.html
index.html:1 Access to XMLHttpRequest at ‘http://localhost:8888/employees’ from origin ‘http://localhost:8080’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
jquery.js:2 GET http://localhost:8888/employees net::ERR_FAILED
send @ jquery.js:2
ajax @ jquery.js:2
p. @ jquery.js:2
mounted @ index.html:30
invokeWithErrorHandling @ vue.js:1863
callHook @ vue.js:4220
mountComponent @ vue.js:4087
Vue. m o u n t @ v u e . j s : 9044 V u

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值