| 176 | } |
| 177 | |
| 178 | function respond(res: ServerResponse, status: number, body: string): void { |
| 179 | res |
| 180 | .writeHead(status, { |
| 181 | "content-type": "text/html; charset=utf-8", |
| 182 | "cache-control": "no-store", |
| 183 | // Tell the browser not to keep the TCP socket alive — otherwise |
| 184 | // `server.close()` blocks on the idle keep-alive timeout |
| 185 | // (Chrome ~5min). Combined with `server.closeAllConnections()` |
| 186 | // in `close()` this guarantees the CLI exits promptly after the |
| 187 | // user sees the success page. |
| 188 | connection: "close", |
| 189 | }) |
| 190 | .end(body); |
| 191 | } |
| 192 | |
| 193 | function successPage(): string { |
| 194 | return `<!doctype html><html><head><meta charset="utf-8"><title>Signed in to HeyGen</title> |