MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / bridgeIfNeeded

Method bridgeIfNeeded

server/src/http.ts:851–863  ·  view source on GitHub ↗
(req: express.Request, res: express.Response)

Source from the content-addressed store, hash-verified

849 // Redirect through AAO session bridge if on AdCP without a session cookie.
850 // Returns true if a redirect was issued (caller should return early).
851 private bridgeIfNeeded(req: express.Request, res: express.Response): boolean {
852 // Skip the bridge for clients that don't send cookies (agents, curl, bots).
853 // They will never have a session to bridge, so the redirect is pointless
854 // and creates an infinite loop for clients without a cookie jar.
855 if (!req.headers.cookie) return false;
856
857 if (this.isAdcpDomain(req) && !req.cookies?.['wos-session'] && !req.cookies?.['bridge-checked']) {
858 const currentUrl = `https://${req.hostname}${req.originalUrl}`;
859 res.redirect(`https://agenticadvertising.org/auth/bridge?return_to=${encodeURIComponent(currentUrl)}`);
860 return true;
861 }
862 return false;
863 }
864
865 /**
866 * Serve an HTML file with APP_CONFIG injected.

Callers 2

setupMiddlewareMethod · 0.95
serveHtmlWithConfigMethod · 0.95

Calls 1

isAdcpDomainMethod · 0.95

Tested by

no test coverage detected