You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Vue.js的vue.config.js中添加devServer配置

合并devServer代理配置到vue.config.js

直接在defineConfig的配置对象中添加devServer属性即可,修改后的完整代码如下:

const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,
  devServer: {
    proxy: 'http://localhost:8080/'
  }
})

修改说明

  • 无需重新定义module.exports,直接在原有defineConfig包裹的配置对象内,新增devServer字段并填入你的代理配置
  • 注意保持对象内语法正确,属性之间用逗号分隔

内容的提问来源于stack exchange,提问作者Aditya Mahajan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 02:09:52