[Vuejs]-Alternative for laravel config() in vue

0👍

The configurations in app/config are specifically used for back end purposes. I’m not aware if there are any packages that allow you to do this as of writing. A quick google on this doesn’t show any thing as well (Might be a good opportunity to create a package for).

Yes you can access your env variables by using process.env but make sure they are prefixed with MIX_ as mentioned in Laravel – Compiling Assets.

So say you have this in your .env:

MIX_FOO=bar
FOO=bar

You can access them in your js with:

process.env.MIX_FOO // bar
process.env.FOO // undefined

Also, making changes to the .env file will not be read once you have compiled you assets, you’ll need to recompile them to take changes.

Leave a comment