Vue 跨域请求报错No ‘Access-Control-Allow-Origin‘ header is present on the requested resource.
坑是一个一个踩出来的。。。
报错如下:
Access to XMLHttpRequest at 'http://apps.eshimin.com/traffic/gjc/getArriveBase?name=***&lineid=***&direction=1&stopid=12' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
我请求的地址是一个第三方的接口,可以从浏览器看出来,是跨域拦截了。直接说修改方法~
config/index.JS--dev环境就修改dev的
proxyTable: {'/apibus':{target:'http://apps.eshimin.com',//接口的域名changeOrigin:true,//是否跨域-是pathRewrite:{'^/apibus':''//对应调用接口的地方,把原来的域名改成apibus}}},
调用接口的代码:
//get 请求接口let _this = this;let url = '/apibus/traffic/gjc/getArriveBase?name=205%E8%B7%AF&lineid=020500&direction=1&stopid=12';_this.$ajax.get(url).then(res => {let cars = res.data.cars;this.busStatus = "205路公交车当前车牌号:"+cars[0].terminal+",剩余时间:"+cars[0].time/60+"分钟,剩余距离:"+cars[0].distance+"米,剩余站:"+cars[0].stopdis;console.log("ok");}).catch(error => {console.log(error);});
Vue 跨域请求报错No ‘Access-Control-Allow-Origin‘ header is present on the requested resource.相关推荐
- 报错:uni-app跨域请求报错
编辑器:HBuilderX 语言架构:uni-app + uview+ luch-Request 报错情况:本地运行后端 jar 包,列表页面访问没有问题,打开子组件详情页却跨域错误.但是换台电脑的情 ...
- 解决跨域问题:No ‘Access-Control-Allow-Origin‘ header is present on the requested resource.
前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家.点击跳转到教程. PS:如果遇到 这个问题 Request header field Content-Type is ...
- vue一级分类和耳机分类_【Vue+DRF生鲜电商】10.商品分类层级获取,Vue跨域请求商品分类...
欢迎访问我的博客专题 源码可访问 Github 查看 DRF实现商品分类获取 实现商品分类层级结构显示 商品类别ViewSet 在商品类别中,不需要对类别进行分页,因为类别的数据量不大,只要在数据量很 ...
- 报错:跨域问题解决 No ‘Access-Control-Allow-Origin‘ header is present on the requested resource.
报错: Access to XMLHttpRequest at 'http://127.0.0.1:8088/user/list' from origin 'http://localhost:8080 ...
- 新版本Chrome同源策略、跨域问题处理No ‘Access-Control-Allow-Origin‘ header is present on the requested resource.
本文的方法实用于本地调试浏览器的设置,如果想要彻底解决需要使用 CORS(跨域资源共享) [ 相关文章 ] Python 使用 CORS 跨域资源共享解决 flask 服务器跨域问题.浏览器同源策略 ...
- 解决springboot跨域问题No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
文章目录 1.问题描述 2.问题产生 3.解决方案 1. 在WebMvcConfig添加(推荐使用) 2.直接采用SpringBoot的注解@CrossOrigin 1.Controller层在需要跨 ...
- js跨域访问,No 'Access-Control-Allow-Origin' header is present on the requested resource
js跨域访问提示错误:XMLHttpRequest cannot load http://...... No 'Access-Control-Allow-Origin' header is prese ...
- Vue--使用webpack解决跨域问题:No ‘Access-Control-Allow-Origin‘ header is present on the requested resource
原文网址:Vue--使用webpack解决跨域问题:No 'Access-Control-Allow-Origin' header is present on the requested resour ...
- header is present on the requested resource. Origin 'null' is therefore not allowed access.
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is there ...
最新文章
- boost::leaf模块读取缓冲区中的文本文件并将其打印到 std::cout
- 腾讯开源首个医疗AI项目,业内首个3D医疗影像大数据预训
- DefaultListableBeanFactory 对配置lazy-init 属性单态Bean 的预实例化
- Redis 使用 Lua 脚本进行原子操作
- path.join 和 path.resolve的区别
- 【HDU - 2012】素数判定(水题,数论,打表)
- python 实现组合数
- “Found interface com.mysql.jdbc.Connection, but class was expected ”
- PMP备考指南之第一章:引论
- itchat python_itchat-python搭建微信机器人(附示例)
- jmeter分布式性能测试
- 解数独(Python)
- python基础语法记录
- mac电脑用计算机名共享打印机,苹果电脑怎么连接共享打印机_苹果电脑连接共享打印机的具体教程-系统城...
- 静态路由和直连路由引入配置
- python 实现省全称和省的简称互相转换
- 201771010102 常惠琢 《面向对象程序设计(java)》第十三周学习总结
- 安装SQL SERVER2019 安装CAB文件问题
- 2022-07-04-5万字长文说清楚到底什么是“车规级”
- “共码未来”——2022Google开发者大会纪行
热门文章
- 2021-2-15 基础语法
- 借助人工智能与机器学习技术 强化物联网安全防护
- 不方便的事情,人们都不大会去做
- 2019年5月30日:新坑C#
- Android报错Failed to allocate a 246498744 byte allocation with 1572864 free bytes and 191MB until OOM,
- Python爬长津湖豆瓣短评
- python图像对比处理_图像处理 | 灰度变换与图像对比度拉伸
- word 2013无法执行撤销操作
- Nokia S60v5 javaME 禁用 softkeypad
- CSS多行省略的几种方法