Myk*_*l_M 5 javascript environment-variables api-key node.js browserify
I've made a few node.js bots and web applications that have used .env variables along with the dotenv package to hold all of the API keys.
However, Im currently working on a website that uses node.js with browserify and this method doesn't seem to work. Whenever I try to output the value to the console or use the value in the code it returns undefined.
我该如何解决这个问题,或者如果 .env 根本无法在网络上工作,我将如何隐藏这些值?
我的 .env 示例
ID = B1CRL2WDIW2553
SECRET = 41445d2b99b33ede3ebce0421900b8e9
Run Code Online (Sandbox Code Playgroud)
我的例子
const dotEnv = require('dotenv').config({path: './.env'});
console.log(process.env.ID);
Run Code Online (Sandbox Code Playgroud)
我通过将 API 密钥和特权信息添加到 firebase 数据库,然后在移交信息之前检查用户身份验证来解决此问题。可以在这里找到教程: https: //firebase.google.com/docs/database/security/
| 归档时间: |
|
| 查看次数: |
3648 次 |
| 最近记录: |