Skip to content

开发/生产环境与后端交互(新手必读) #91

@sendya

Description

@sendya

如何在开发环境,生产环境访问后端接口
与 devServer 相关的问题请自行查询 API 文档,未给出链接的,请自行百度谷歌

基础知识须知

  1. Vue Cli3 devServer.proxy 配置参考
  2. Webpack devServer.proxy 配置参考
  3. Nginx/Apache 等 web 服务器反向代理
  4. CORS 跨域问题

开发环境采用 WebpackdevServer

Cli3 配置

devServer: {
    proxy: {
      '/api': {
        target: 'http://localhost:8080/api',
        ws: false,
        changeOrigin: true,
        pathRewrite: {
          '^/api': ''
        }
      },
      '/api/xxxx': {
        target: 'http://localhost:8080/api',
        ws: false,
        changeOrigin: true,
        pathRewrite: {
          '^/api': ''
        }
      }
    }

也可以参考 Github 上其他开源者的 devServer 配置项
ref https://github.com/PanJiaChen/vue-element-admin/blob/master/vue.config.js

生产环境

参考 Issue #41

Pro 官方文档

参考文档 https://pro.antdv.com/docs/deploy

注: 请不要在本 Issue 提问

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions