()
| 24 | } |
| 25 | |
| 26 | function assertPublicRuntimeGuard() { |
| 27 | const [, , command, ...args] = process.argv; |
| 28 | const port = readCliPort(args)?.trim(); |
| 29 | const isPublicStart = command === "start" && port === PUBLIC_PORT; |
| 30 | if (!isPublicStart) { |
| 31 | return; |
| 32 | } |
| 33 | |
| 34 | const startedByWrapper = process.env.MC_RUNTIME_WRAPPER === "dev-server"; |
| 35 | const allowedPublicRuntime = |
| 36 | process.env.MC_ALLOW_PUBLIC_RUNTIME === "1" && |
| 37 | process.env.NODE_ENV === "production" && |
| 38 | distDir === PUBLIC_DIST_DIR; |
| 39 | |
| 40 | if (startedByWrapper || allowedPublicRuntime) { |
| 41 | return; |
| 42 | } |
| 43 | |
| 44 | throw new Error( |
| 45 | `[mission-control] Refusing to start public port ${PUBLIC_PORT} without an approved Mission Control runtime. Use "node scripts/dev-server.cjs --port ${PUBLIC_PORT}" for wrapper mode, or run the production public runtime with MC_ALLOW_PUBLIC_RUNTIME=1 and NEXT_DIST_DIR=${PUBLIC_DIST_DIR} (mission-control.service does this automatically).` |
| 46 | ); |
| 47 | } |
| 48 | |
| 49 | assertPublicRuntimeGuard(); |
| 50 |
no test coverage detected