Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.env.development VUE_APP_BASE_API 默认配置内容修正 #96

Open
ckwillling opened this issue Sep 29, 2022 · 0 comments
Open

.env.development VUE_APP_BASE_API 默认配置内容修正 #96

ckwillling opened this issue Sep 29, 2022 · 0 comments

Comments

@ckwillling
Copy link

Describe the bug
项目clone下来后, 本地运行, 希望api能走本地服务, 因此参考 .env.development 修改了 配置

# base ap
# VUE_APP_BASE_API = 'http://local.vma.isocked.com/api'
VUE_APP_BASE_API = 'http://127.0.0.1:5005/api'

vue.config.js 配置了devServer

  devServer: {
    host: '127.0.0.1',
    port: 8000,
    proxy: {
      '/api': {
        target: 'http://127.0.0.1:5005/',
        ws: false,
        changeOrigin: true,
        pathRewrite: {
          // '/api/': '/api/',
        },
      },
    },
  },

确实请求到了本地服务, 但不是通过代理, 而是直接跨域到了5005端口的服务.

因为非前端开发, 因此花了大半天的时间才找到原因,

# base ap
# VUE_APP_BASE_API = 'http://local.vma.isocked.com/api'
VUE_APP_BASE_API = '/api'

即可解决

花了这么长时间一个是因为前端不熟, 再一个是受原始 VUE_APP_BASE_API的配置内容和方式影响, 自然而然的配置了一个带域名的VUE_APP_BASE_API.

因此希望将 .env.development 的 VUE_APP_BASE_API 改成 /api, 降低出错的概率. 谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant