I'm having an issue with deploying to Heroku.
Just before server.listen(process.env.PORT || 3000)
console.log(process.env.PORT)
gives me 3000
but console.log(JSON.stringify(process.env))
gives me the entire object with PORT set correctly by Heroku (It uses a different port each time)
My money is on the minification process that changes process.env.PORT
variable name to something like 3e3
and then the port isn't read correctly for some reason.
(When I upload a dev build to heroku everything works)
Any idea how can I disable server minification on production?
OK, did some more research and found this from RAZZLE-README.md
The environment variables are embedded during the build time. You can read them at runtime just because by default we export them with the
webpack.DefinePlugin
.
so process.env.PORT is set at build time. this won't do for Heroku since it needs to set it itself. what can I do here ?
Solved! :)
found this little cutie: https://www.npmjs.com/package/razzle-heroku
works like a charm! 🥇
And I was already starting to consider ditching razzle and roll my own ..
For anyone coming here there is options for this in the new razzle coming out soon.
Most helpful comment
Solved! :)
found this little cutie: https://www.npmjs.com/package/razzle-heroku
works like a charm! 🥇
And I was already starting to consider ditching razzle and roll my own ..