INNER CODE UNIT · TypeScript

dispatch

colyseus/colyseus · packages/admin/src-backend/index.ts:571

      const dispatch = (handler: (rq: any, rs: any) => Promise<void>) => {
        const headers: typeof req.headers = { ...req.headers };
        // Internal mount-coordinate headers — always ours, never the client's
        delete headers['x-colyseus-admin-base'];
        delete headers['x-colyseus-admin-api'];
        if (mount) {
          const fwd = req.headers['x-forwarded-prefix'];
          const proxy = safePath(typeof fwd === 'string' ? fwd : null);
          headers['x-colyseus-admin-base'] = `${proxy}${mount}/`;
          headers['x-colyseus-admin-api'] = `${proxy}${mount}${ctx.apiPath}`;
        }
        // better-call's getRequest resolves the URL as baseUrl + url
        const wrapped = Object.create(req, {
          url: { value: dispatchPath + query, enumerable: true, configurable: true },
          baseUrl: { value: '', enumerable: true, configurable: true },
          originalUrl: { value: dispatchPath + query, enumerable: true, configurable: true },
          headers: { value: headers, enumerable: true, configurable: true },
        });

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…