fix(oauth): keep open external so xAI/Grok token refresh works on Windows
`open` derives its own directory from import.meta.url at module scope. Webpack replaces that with the build machine's absolute path as a string literal, so a release built on macOS ships a file:///Users/... URL that fileURLToPath rejects on Windows (no drive letter), throwing on import. refreshXaiToken dynamic-imports the xAI OAuth service, which imports open eagerly, so every Grok token refresh silently failed and was swallowed by a catch that only logs a warning. Add open to serverExternalPackages so it keeps its real import.meta.url at runtime, and bundle it into the CLI package via ensureModuleInBundle (same guard already used for sql.js) since externalizing it means webpack no longer traces/copies it automatically.
This commit is contained in:
@@ -13,7 +13,14 @@ const proxyClientMaxBodySize = process.env.NINEROUTER_PROXY_CLIENT_MAX_BODY_SIZE
|
||||
const nextConfig = {
|
||||
distDir: process.env.NEXT_DIST_DIR || ".next",
|
||||
output: "standalone",
|
||||
serverExternalPackages: ["better-sqlite3", "sql.js", "node:sqlite", "bun:sqlite"],
|
||||
// `open` must stay external. It derives its own directory from `import.meta.url`, and
|
||||
// webpack replaces that with the absolute path of the BUILD machine as a string literal.
|
||||
// A release built on macOS therefore ships `file:///Users/.../open/index.js`, which
|
||||
// `fileURLToPath` rejects on Windows ("File URL path must be absolute" — no drive
|
||||
// letter). That throw happens at module scope, so every consumer of `open` dies on
|
||||
// import — including xAI/Grok token refresh, which loads the OAuth service that imports
|
||||
// it. Keeping it external preserves the real `import.meta.url` at runtime.
|
||||
serverExternalPackages: ["better-sqlite3", "sql.js", "node:sqlite", "bun:sqlite", "open"],
|
||||
turbopack: {
|
||||
root: tracingRoot
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user