fix: do not set default host to localhost (#9957)
Fixes bug introduced by https://github.com/medusajs/medusa/pull/9912 By default the Node.js server listens on the `0.0.0.0` host. However, the related PR changes the host to `localhost` and hence resulted in an unwanted breaking change. This PR reverts the default value assignment and let Node.js decide the host when not explicitly specified.
This commit is contained in:
1 parent
c1c85ef952
commit
b0f416769f
2 files changed
+11
-12
No files matched your search
@@ -18,8 +18,7 @@ const handlerP =
|
|||||||
}
|
}
|
||||||
|
|
||||||
function buildLocalCommands(cli, isLocalProject) {
|
function buildLocalCommands(cli, isLocalProject) {
|
||||||
const defaultHost = `localhost`
|
const defaultPort = "9000"
|
||||||
const defaultPort = `9000`
|
|
||||||
const directory = path.resolve(`.`)
|
const directory = path.resolve(`.`)
|
||||||
|
|
||||||
const projectInfo = { directory }
|
const projectInfo = { directory }
|
||||||
@@ -290,10 +289,10 @@ function buildLocalCommands(cli, isLocalProject) {
|
|||||||
.option(`H`, {
|
.option(`H`, {
|
||||||
alias: `host`,
|
alias: `host`,
|
||||||
type: `string`,
|
type: `string`,
|
||||||
default: process.env.HOST || defaultHost,
|
default: process.env.HOST,
|
||||||
describe: process.env.HOST
|
describe: process.env.HOST
|
||||||
? `Set host. Defaults to ${process.env.HOST} (set by env.HOST) (otherwise defaults ${defaultHost})`
|
? `Set host. Defaults to ${process.env.HOST} (set by env.HOST)`
|
||||||
: `Set host. Defaults to ${defaultHost}`,
|
: "",
|
||||||
})
|
})
|
||||||
.option(`p`, {
|
.option(`p`, {
|
||||||
alias: `port`,
|
alias: `port`,
|
||||||
@@ -328,10 +327,10 @@ function buildLocalCommands(cli, isLocalProject) {
|
|||||||
.option(`H`, {
|
.option(`H`, {
|
||||||
alias: `host`,
|
alias: `host`,
|
||||||
type: `string`,
|
type: `string`,
|
||||||
default: process.env.HOST || defaultHost,
|
default: process.env.HOST,
|
||||||
describe: process.env.HOST
|
describe: process.env.HOST
|
||||||
? `Set host. Defaults to ${process.env.HOST} (set by env.HOST) (otherwise defaults ${defaultHost})`
|
? `Set host. Defaults to ${process.env.HOST} (set by env.HOST)`
|
||||||
: `Set host. Defaults to ${defaultHost}`,
|
: ``,
|
||||||
})
|
})
|
||||||
.option(`p`, {
|
.option(`p`, {
|
||||||
alias: `port`,
|
alias: `port`,
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ function displayAdminUrl({
|
|||||||
port,
|
port,
|
||||||
container,
|
container,
|
||||||
}: {
|
}: {
|
||||||
host: string
|
host?: string
|
||||||
port: string | number
|
port: string | number
|
||||||
container: MedusaContainer
|
container: MedusaContainer
|
||||||
}) {
|
}) {
|
||||||
@@ -84,7 +84,7 @@ function displayAdminUrl({
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(`Admin URL → http://${host}:${port}${adminPath}`)
|
logger.info(`Admin URL → http://${host || "localhost"}:${port}${adminPath}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function start(args: {
|
async function start(args: {
|
||||||
@@ -94,7 +94,7 @@ async function start(args: {
|
|||||||
types?: boolean
|
types?: boolean
|
||||||
cluster?: number
|
cluster?: number
|
||||||
}) {
|
}) {
|
||||||
const { port = 9000, host = "localhost", directory, types } = args
|
const { port = 9000, host, directory, types } = args
|
||||||
|
|
||||||
async function internalStart(generateTypes: boolean) {
|
async function internalStart(generateTypes: boolean) {
|
||||||
track("CLI_START")
|
track("CLI_START")
|
||||||
@@ -142,7 +142,7 @@ async function start(args: {
|
|||||||
http_.listen(port, host).on("listening", () => {
|
http_.listen(port, host).on("listening", () => {
|
||||||
logger.success(
|
logger.success(
|
||||||
serverActivity,
|
serverActivity,
|
||||||
`Server is ready on http://${host}:${port}`
|
`Server is ready on http://${host || "localhost"}:${port}`
|
||||||
)
|
)
|
||||||
displayAdminUrl({ container, host, port })
|
displayAdminUrl({ container, host, port })
|
||||||
track("CLI_START_COMPLETED")
|
track("CLI_START_COMPLETED")
|
||||||
|
|||||||
Reference in new issue
Block a user