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.
check this package for node.js dotenv
You can define path to .env
file
as
require('dotenv').config({path: '/custom/path/to/laravel/'});
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