Skip to content

Missing PORT variable #166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions serve/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const DEFAULT_PORT = 8080
const HOST = process.env.HOST || '0.0.0.0'
const protocol = 'https'
const useLocalhost = process.env.USE_LOCALHOST === 'true'
const SELECT_PORT = process.env.PORT || DEFAULT_PORT;

///////////////////////////////////////////////////////////////////////////////
let https = true
Expand Down Expand Up @@ -113,7 +114,7 @@ config.plugins.push(new HtmlWebpackPlugin({
// enable hot reloading
if (process.env.NO_RELOAD !== "true") {
config.entry.app.unshift(path.resolve(__dirname, '..', 'node_modules', 'webpack-dev-server/client/index.js')
+ `?${protocol}://${useLocalhost ? 'localhost' : address}:${PORT}`)
+ `?${protocol}://${useLocalhost ? 'localhost' : address}:${SELECT_PORT}`)
config.devServer = { inline: "true" }
}

Expand All @@ -136,7 +137,7 @@ compiler.plugin('done', stats => {
}) // end compiler.plugin on done

// Find available port and launch WebpackDevServer
nextAvailable(process.env.PORT || DEFAULT_PORT).then((PORT) => {
nextAvailable(SELECT_PORT).then((PORT) => {
// Exit if user defined port is in use
if (process.env.PORT && (process.env.PORT != PORT)) {
console.log('ERROR: Port ' + process.env.PORT + ' is in use by another process.')
Expand Down