Skip to content

chore(release): 0.15.1 - #34

Merged
vreshch merged 2 commits into
masterfrom
fix/request-log-original-url
Aug 13, 2026
Merged

chore(release): 0.15.1#34
vreshch merged 2 commits into
masterfrom
fix/request-log-original-url

Conversation

@vreshch

@vreshch vreshch commented Aug 13, 2026

Copy link
Copy Markdown
Member

Defect

createRequestLog read req.path inside the res 'finish' listener. By then, for a request that ended inside a mounted router (e.g. a guard 401 on a router mounted at /api/admin), Express has rewritten req.path/req.baseUrl to be router-relative - so the log line carried path: "/whoami" instead of "/api/admin/whoami", and the routeFromUrl fallback normalized the same truncated value. Found during today's estate rollout.

Requests that match a handler were unaffected.

Fix

Capture the identity once at middleware entry:

const originalPath = (req.originalUrl ?? req.path).split('?')[0];
  • originalUrl added as an optional field on the structurally-typed RequestLogRequest (no express dependency).
  • Used for the path field and as the routeFromUrl fallback input.
  • The matched-route template still comes from baseUrl + route.path, evaluated at finish as before.

Tests

Three new cases in test/request-log.test.ts:

  • mounted-router rejection: req mutated to router-relative between entry and finish, log still carries /api/admin/whoami for both path and route.
  • query string stripped from originalUrl.
  • originalUrl preferred over the rewritten path for the RegExp-route fallback.

226 tests green (npm run verify), existing cases unchanged.

Release

PR title is chore(release): 0.15.1 so the squash commit trips the publish gate in .github/workflows/release.yml - merging publishes 0.15.1 to npm. Lockfile diff is version fields only.

@vreshch
vreshch marked this pull request as ready for review August 13, 2026 22:45
@vreshch
vreshch merged commit ba71e11 into master Aug 13, 2026
1 check passed
@vreshch
vreshch deleted the fix/request-log-original-url branch August 13, 2026 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant