【问题标题】:Nuxt Environment variable with docker (compose)Nuxt 环境变量与 docker (compose)
【发布时间】:2022-06-11 03:10:38
【问题描述】:

我有一个使用 env 的 Nuxt 插件 通过process.env.API_URL 读取的“API_URL”在本地主机上工作,但不使用 docker 部署

docker-compose(部分)

    environment:
      - API_URL=https://xxx.xxx.de/api/api/v1/
      - BASE_URL=https://xxx.xxx.de/

部署的容器

echo $API_URL
https://xxx.xxx.de/api/api/v1

但它请求 https://xxx.xxx.de/disease/?usedOnly= 而不是 https://xxx.xxx.de/api/api/v1/disease/?usedOnly=

前端日志

> portal@1.0.0 start
> HOST=0.0.0.0 nuxt start

:information_source: Listening on: http://172.10.10.10:3000/

 ERROR  window is not defined

  at Object.errorHandler (pages/index.js:398:5)
  at pages/index.js:649:12
  at processTicksAndRejections (node:internal/process/task_queues:96:5)


 ERROR  window is not defined

  at Object.errorHandler (pages/index.js:398:5)
  at pages/index.js:655:12
  at processTicksAndRejections (node:internal/process/task_queues:96:5)


 ERROR  window is not defined

  at Object.errorHandler (pages/index.js:398:5)
  at pages/index.js:409:12
  at processTicksAndRejections (node:internal/process/task_queues:96:5)

【问题讨论】:

    标签: docker docker-compose nuxt.js httprequest


    【解决方案1】:

    你试过了吗?也许它可能会有所帮助?

    • API_URL=https://xxx.xxx.de
    • BASE_URL=https://xxx.xxx.de

    【讨论】:

    • 是的。我试过了,但是整个网站抛出一个错误 500
    • 这应该是评论而不是答案。
    猜你喜欢
    • 1970-01-01
    • 2015-06-17
    • 1970-01-01
    • 2018-08-07
    • 2022-01-01
    • 2018-02-03
    • 2019-02-25
    • 2019-07-26
    • 1970-01-01
    相关资源
    最近更新 更多