打开config->index.js 配置其中的proxyTable

module.exports = {
dev: { // Paths
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {
'/api': {
target: 'http://118.25.52.204:3200', //目标接口域名
changeOrigin: true, //是否跨域
pathRewrite: {
'^/api': '' //重写接口
}
}
}, // Various Dev Server settings
host: 'localhost', // can be overwritten by process.env.HOST
port: , // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
autoOpenBrowser: false,
errorOverlay: true,
notifyOnErrors: true,
poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions- // Use Eslint Loader?
// If true, your code will be linted during bundling and
// linting errors and warnings will be shown in the console.
useEslint: true,
// If true, eslint errors and warnings will also be shown in the error overlay
// in the browser.
showEslintErrorsInOverlay: false, /**
* Source Maps
*/ // https://webpack.js.org/configuration/devtool/#development
devtool: 'cheap-module-eval-source-map', // If you have problems debugging vue-files in devtools,
// set this to false - it *may* help
// https://vue-loader.vuejs.org/en/options.html#cachebusting
cacheBusting: true, cssSourceMap: true
},

在main.js中写入

Vue.prototype.HOST = "/api"

webpack跨域配置处理的更多相关文章

  1. Asp.Net Core跨域配置

    在没有设置跨域配置的时候,Ajax请求时会报以下错误 已拦截跨源请求:同源策略禁止读取位于 http://localhost:5000/Home/gettime 的远程资源.(原因:CORS 头缺少 ...

  2. Springboot统一跨域配置

    前言:跨域是什么? 要知道跨域的概念,我们先明确怎样算是同一个域: 同一个域指的是同一协议,同一ip,同一端口 如果这三同中有一者不同就产生了跨域. 在做前后端分离的项目中,通过ajax请求后台端口时 ...

  3. Asp.net跨域配置

    <system.webServer> <httpProtocol> <customHeaders> <add name="Access-Contro ...

  4. asp.net (webapi) core 2.1 跨域配置

    原文:asp.net (webapi) core 2.1 跨域配置 官方文档 ➡️ https://docs.microsoft.com/zh-cn/aspnet/core/security/cors ...

  5. .net core api服务端跨域配置

    第1步:添加包引用(.net core 2.2 已自带此包,可跳过此步骤) Install-Package Microsoft.AspNetCore.Cors 第2步:在Startup.cs文件的Co ...

  6. nginx-springboot-vue前后端分离跨域配置

    nginx-springboot-vue前后端分离跨域配置 引言 接着上篇--简单的springboot-vue前后端分离登录Session拦截的demo,其中跨域是通过springboot后端全局设 ...

  7. 常见跨域解决方案以及Ocelot 跨域配置

    常见跨域解决方案以及Ocelot 跨域配置 Intro 我们在使用前后端分离的模式进行开发的时候,如果前端项目和api项目不是一个域名下往往会有跨域问题.今天来介绍一下我们在Ocelot网关配置的跨域 ...

  8. [PHP] Laravel5.5 使用 laravel-cors 实现 Laravel 的跨域配置

    Laravel5.5  使用 laravel-cors 实现 Laravel 的跨域配置 最开始的时候,我使用的是路由中间件的方式,但是发现中间件不起作用 这是之前使用的方式: 'cros' => ...

  9. asp.net core api 跨域配置

    项目前后端分离,前端请求接口例如使用axios发送请求时浏览器会提示跨域错误,需要后端配置允许接口跨域 配置步骤: 1.通过NuGet安装Microsoft.AspNetCore.Cors.dll类库 ...

随机推荐

  1. time模块 random模块

    time模块 time.sys等模块是C语言实现的,内置到了python解释器的.而不是py文件. 导入模块的时候,优先到python解释器,然后才会找py文件. #时间戳 #计算 # print(t ...

  2. 028_go语言中的超时处理

    代码演示 package main import "fmt" import "time" func main() { c1 := make(chan strin ...

  3. 027_go语言中的通道选择器

    代码演示 package main import "fmt" import "time" func main() { c1 := make(chan strin ...

  4. 一招教你如何在Python中使用Torchmoji将文本转换为表情符号

    很难找到关于如何使用Python使用DeepMoji的教程.我已经尝试了几次,后来又出现了几次错误,于是决定使用替代版本:torchMoji. TorchMoji是DeepMoji的pyTorch实现 ...

  5. 响应式Web设计与CSS(上)

    1.一个例子 响应式Web设计最核心的一点,就是可以适配不同视口大小的流式布局. 1.1 简单上手 <div class="row"> <header class ...

  6. JAVA多线程之生产者 消费者模式 妈妈做面包案例

    创建四个类 1.面包类 锅里只可以放10个面包 ---装面包的容器2.厨房 kitchen 生产面包 和消费面包  最多生产100个面包3.生产者4消费者5.测试类 多线程经典案例 import ja ...

  7. 解决drf_yasg中的SwaggerAPI无法正确分组问题

    swagger是后台开发中很好用的交互式文档,Django原本的Django-Swagger已经停止维护了,现在一般用drf_yasg这个包来实现文档,它里面支持swagger和redoc两种,red ...

  8. C#LeetCode刷题之#414-第三大的数(Third Maximum Number)

    问题 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/3710 访问. 给定一个非空数组,返回此数组中第三大的数.如果不存 ...

  9. 熵权法原理及matlab代码实现

    参考原理博客地址https://blog.csdn.net/u013713294/article/details/53407087 一.基本原理 在信息论中,熵是对不确定性的一种度量.信息量越大,不确 ...

  10. for循环的插入元素

    Scanner input = new Scanner(System.in);  int[] num = new int[5];  for (int i = 0; i < num.length; ...