Spaces:
Sleeping
Sleeping
fix: use server-side URL rewrite instead of 302 redirect for token injection
Browse files302 redirect was unreliable in incognito mode — the browser followed
the redirect but OpenClaw's frontend sometimes failed to pick up the
token. Server-side rewrite injects the token directly into req.url
before OpenClaw processes it, eliminating the redirect round-trip.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
214 unmodified lines215216217218219220221222223224225226214 unmodified linesreturn origEmit.apply(this, [event, ...args]);}} else {// Default mode: redirect GET / to /?token=xxxif (req.method === 'GET' && !req.headers.upgrade) {if (pathname === '/' && !parsed.query.token) {res.writeHead(302, { Location: `/?token=${GATEWAY_TOKEN}` });res.end();return true;}}}214 unmodified lines215216217218219220221222223224225214 unmodified linesreturn origEmit.apply(this, [event, ...args]);}} else {// Default mode: rewrite URL to inject token (no redirect needed)if (req.method === 'GET' && !req.headers.upgrade) {if (pathname === '/' && !parsed.query.token) {req.url = `/?token=${GATEWAY_TOKEN}`;return origEmit.apply(this, [event, ...args]);}}}
scripts/token-redirect.cjs+3-4