Skip to content

Commit d9c6aeb

Browse files
committed
Default CODERV2_HOST to local server on :3000
1 parent 974c654 commit d9c6aeb

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

site/scripts/dev.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@ import next from "next"
55
const port = process.env.PORT || 8080
66
const dev = process.env.NODE_ENV !== "production"
77

8-
if (!process.env.CODERV2_HOST) {
9-
throw new Error("CODERV2_HOST must be set")
10-
} else if (!/^http(s)?:\/\//.test(process.env.CODERV2_HOST)) {
11-
throw new Error("CODERV2_HOST must be http(s)")
8+
let coderV2Host = "http://127.0.0.1:3000"
9+
10+
if (process.env.CODERV2_HOST) {
11+
if (!/^http(s)?:\/\//.test(process.env.CODERV2_HOST)) {
12+
throw new Error("CODERV2_HOST must be http(s)")
13+
} else {
14+
coderV2Host = process.env.CODERV2_HOST
15+
}
1216
}
1317

18+
console.log(`Using CODERV2_HOST: ${coderV2Host}`)
19+
1420
const app = next({ dev, dir: "./site" })
1521
const handle = app.getRequestHandler()
1622

@@ -21,7 +27,7 @@ app
2127
server.use(
2228
"/api",
2329
createProxyMiddleware("/api", {
24-
target: process.env.CODERV2_HOST,
30+
target: coderV2Host,
2531
ws: true,
2632
secure: false,
2733
changeOrigin: true,

0 commit comments

Comments
 (0)