Skip to content
This repository was archived by the owner on Apr 14, 2025. It is now read-only.
This repository was archived by the owner on Apr 14, 2025. It is now read-only.

mocking request loses original koa app instance, breaking resolving of req.subdomains, because req.app.subdomainOffset is undefined #129

@falkenhawk

Description

@falkenhawk

request.subdomains getter depends on request.app.subdomainOffset, which can be configured after koa is instantiated:

e.g. for hostname app.example.com original ctx.subdomains would resolve to ['app'] (with koa's default subdomainOffset = 2), and mocked req.subdomains would resolve to ['com', 'example', 'app'].

(This is breaking passport authentication for us because we are resolving tenants from subdomains, and at the same time we are checking jwt's issuer if it matches the subdomain)

Of course I can workaround it, but nevertheless I'd consider it as a bug. What's interesting, koa-passport initially delegated original app object in req.app but then, probably with this change: 0b7da65 it began to overwrite app with that almost-empty mock, which can only return trust proxy property and nothing besides that.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions