I'm deploying a vue.js client with a node.js server to Heroku and fighting through the issues.
I have several oauth "config variables" defined in the Heroku app (using the admin interface) that I can see with heroku config
at the command line, but they are not showing up in the app.
I am inspecting process.env
in router.js. The process.env
simply has NODE_ENV="production" and BASE_URL="/" in it.
So, I had a thought. Hmmm. In vue.js during dev, you cannot use dotenv, you must define your constants in .env as "VUE_APP_XXX", thus: VUE_APP_MY_VAR=YOWASSUP, and vue cli will load them into process.env
. Yesterday, I had defined all my heroku config vars as "VUE_APP_..." and then changed them today so I could use the "VUE_APP_XXX" in my .env, and use the "XXX" format for Heroku config vars. Smart eh!?
Well, no. That leads to my question. I just tested and all Heroku-defined vue.js vars MUST be named with the pattern "VUE_APP_..." to be parsed and placed in process.env
.
I don't think this is expected behaviour. I know the VUE_APP_... pattern is fairly new. Is this a bug in vue.js, or did I miss the memo? I would not expect it to behave in production the same way as it does in dev, and I certainly would not expect the vue.js app to IGNORE the Heroku-defined constants. I've searched and searched and see nothing about this anywhere.
Also, in order to see the updated Heroku config vars, you must recompile the slug. The report from Heroku about config vars triggering a rebuild are untrue:
From Heroku doco:
Whenever you set or remove a config var using any method, your app is restarted and a new release is created.
The above statement, as far as I can tell in my limited experience, seem to be incorrect.
I had the same issue. I was searching how to have the Heroku config vars as environment variables as they weren't injected on the process.env.
The problem is I wasn't adding the right prefix on the config vars VUE_APP_
. After I changed the config var names and re-deploy the application it worked.
If you're reading variables from a .env file, did you tried:
require('dotenv').config();