更改nuxt构建完成后的客户端配置

问题描述 投票:0回答:1

我想知道是否有可能改变客户端的配置之后,nuxt建设发生了。情况是:一旦建立,部署与一些配置varations多个ENVS。

我很清楚,你可以影响一些参数与环境变量(如API_URL),但似乎并没有影响到客户端执行。

例:

  • 具有nuxt.config.js axios.baseURL =火/ V1
  • nuxt构建
  • nuxt启动
  • 服务器和客户端的请求,请访问API / V1
  • 设置环境变量API_URL = API / v2的
  • nuxt启动(不重建)
  • 服务器端请求去API / V2,客户端请求到达API / V1。预期的行为:服务器和客户端的请求去API / V2什么我失踪?

谢谢你的帮助 !塞德里克

nuxt.js
1个回答
1
投票

您可以使用nuxt-ENV模块https://github.com/samtgarson/nuxt-env

export default {
  computed: {
    testValue () { return this.$env.TEST_VALUE }
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.