I like this method too, the downsides is that you need to add a package for production and import dotenv/config in every single file you use it.
But the good thing is that you can still use the VITE_ prefixed variables on the client, and non-prefixed ones in the server in files files hooks and endpoints, without the client know about them.
I only think VITE shoud expose non-prefixed ones to server only automatically, and VITE_ prefixed ones to both server and client, I simply don't know why on earth this isn't the default behaviour.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I like this method too, the downsides is that you need to add a package for production and import
dotenv/config
in every single file you use it.But the good thing is that you can still use the
VITE_
prefixed variables on the client, and non-prefixed ones in the server in files files hooks and endpoints, without the client know about them.I only think VITE shoud expose non-prefixed ones to server only automatically, and
VITE_
prefixed ones to both server and client, I simply don't know why on earth this isn't the default behaviour.