How to access laravel env variables in node js?

偶尔善良 提交于 2019-12-06 04:42:15

问题


I'm trying to access APP_KEY env variable of laravel in my socket.io server installation, but don't know how to access any of the laravel environment variables.

Any help is appreciated.


回答1:


check this package for node.js dotenv

You can define path to .env file as

require('dotenv').config({path: '/custom/path/to/laravel/'});




回答2:


If they’re defined in the .env file then you can’t: it’s a PHP package Laravel uses that reads those values and makes them available in the application.

Instead, set actual environment variables on your server or in your host definition. Then both your Laravel application and any other application will be able to read them.



来源:https://stackoverflow.com/questions/35483064/how-to-access-laravel-env-variables-in-node-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!