'Heroku node app running error code=H10 despite using `process.env.PORT`
From what I learned from the documentation this error is because of a wrong port, but I use process.env.PORT in stead of localhost:3000 where I am running it locally and it still doesn't work.
Here is my code:
module.exports = env => {
let CLIENT_PORT;
let SERVER_PORT;
let CLIENT_LOG_LEVEL;
let BUILD_DIRECTORY_PREFIX;
if (env) {
//CLIENT_PORT = env.CLIENT_PORT;
//SERVER_PORT = env.SERVER_PORT;
CLIENT_PORT = process.env.PORT || 3000
SERVER_PORT = process.env.PORT || 3000
CLIENT_LOG_LEVEL = JSON.stringify(env.CLIENT_LOG_LEVEL || 'ERROR');
BUILD_DIRECTORY_PREFIX = env.BUILD_DIRECTORY_PREFIX;
}
return {
entry: { app: './src/entry.js' },
devServer: { hot: true, open: true, port: CLIENT_PORT },
module: MODULE_RULES,
output: { filename: "bundle.js", path: path.resolve(BUILD_DIRECTORY_PREFIX, './client/dist/public/') },
performance: { hints: false },
plugins: [
new CleanWebpackPlugin(),
new webpack.DefinePlugin({'process.env.SERVER_PORT': SERVER_PORT}),
new webpack.DefinePlugin({'process.env.CLIENT_LOG_LEVEL': CLIENT_LOG_LEVEL}),
new HtmlWebpackPlugin({ template: 'templates/index.html', favicon: "templates/favicon.ico" }),
new webpack.HotModuleReplacementPlugin()
]
};
};
I tried both running process.env.PORT || 3000 and process.env.PORT || 80 but nothing works. Any ideas what might be the problem?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
