1.总结问题
我们正在使用配置模块(节点),该模块允许我们使用Firebase托管应用设置各种配置选项,例如数据库设置或其他api端点设置.
如果APP_ENV变量设置为'dev',则它指向dev api的实例和数据库设置,与'test'和'prod'相同.
在容器中运行时,我们仅具有一个shell脚本,该脚本可设置APP_ENV然后运行服务器,并选择正确的配置设置.
我们如何通过Firebase托管做到这一点?
使用: github/lorenwest/node-config
2.提供背景,包括您已经尝试过的内容
查看了文档,却一无所获.
3.显示一些代码
github/lorenwest/node-config
4.描述预期和实际结果,包括任何错误消息
预期:根据环境(开发,测试,生产),部署到Firebase并让Web应用访问正确的资源(API端点,数据库设置).
解决方案我遇到了类似的问题. 我用NODE_CONFIG_ENV覆盖了NODE_CONFIG
//for production process.env.NODE_CONFIG_ENV = "default"; //for development process.env.NODE_CONFIG_ENV = "production";参考文献: [1] github/lorenwest/node-config/wiki /环境变量
1. Summarize the problem
We are using a configuration module (node) that allows us to set various configuration options, for example database settings or other api endpoint settings with our firebase hosted app.
if the APP_ENV variable is set to 'dev', then it points to the dev api's instances and database settings, same with 'test', and 'prod'.
When running in a container, we simply have a shell script that sets APP_ENV and then runs the server, and the right configuration settings are chosen.
How do we do this with Firebase hosting?
Using: github/lorenwest/node-config
2. Provide background including what you've already tried
Looked over documentation, found nothing.
3. Show some code
github/lorenwest/node-config
4. Describe expected and actual results including any error messages
Expected: Deploy to Firebase and have the web app access the correct resources (api end points, database settings), based on environment (dev, test, prod).
解决方案I was facing a similar problem. I used NODE_CONFIG_ENV to override NODE_CONFIG
//for production process.env.NODE_CONFIG_ENV = "default"; //for development process.env.NODE_CONFIG_ENV = "production";References: [1]github/lorenwest/node-config/wiki/Environment-Variables
更多推荐
如何在运行时或部署时设置环境变量以选择正确的配置
发布评论