@lenne.tech/nest-server 12.6.14 → 12.6.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -174,7 +174,7 @@ load-bearing (it has since grown back to as many as 20, mostly as new advisories
174
174
  and they were removed, leaving `@graphql-tools/utils` and `multer`, both on an upstream EXACT pin with
175
175
  an open advisory. Those two left on 2026-10-29 (nest-server 12.1.0), once `@nestjs/graphql` 14.1.0 and
176
176
  `@nestjs/platform-express` 12.3.2 moved their pins past the fixes: **the set is empty** (`overrides: {}`,
177
- written explicitly so `check:overrides` reads it as a decision). An override is only necessary if removing it lets the package resolve
177
+ written explicitly so `check:overrides` reads it as a decision). Since 12.6.15 a further entry, `i18next` 26 -> 26.4.4: `@compodoc/compodoc` 2.0.0 exact-pins 26.3.3, and GHSA-6jcc-5g8w-32mx reached GitHub's global database on 2026-11-24, so `pnpm audit` failed the build (dev tooling only; the same entry the current line carries since 12.10.0). An override is only necessary if removing it lets the package resolve
178
178
  back INTO its vulnerable range (verify with a with/without lockfile diff; `pnpm audit` is the arbiter).
179
179
  "Cheap insurance against a parent re-pinning downwards" is not a reason to keep one: `pnpm audit` and
180
180
  `check:overrides` run on every `check` and report such a regression the day it happens. Each surviving entry carries its CVE rationale as a comment. Remove an entry once its parent dependency ships a fixed version.
@@ -410,7 +410,7 @@ pnpm run check:mutations -- --id=<id> # one mutation
410
410
  pnpm run check:mutations -- --list # the registry, without running anything
411
411
  pnpm run check:mutations -- --allow-dirty # when the fix and its evidence share a working tree
412
412
  pnpm run check:mutations -- --jobs=4 # N mutations at a time (default: 2, or 4 on >=12 cores)
413
- pnpm run check:mutations -- --no-infra # only the 437 that need no MongoDB
413
+ pnpm run check:mutations -- --no-infra # only the 438 that need no MongoDB
414
414
  pnpm run check:mutations -- --since=<ref> # only mutations touching files changed since <ref>
415
415
  pnpm run check:mutations -- --shard=2/4 # this job's quarter of the selection (CI splits the full run)
416
416
  ```
@@ -430,7 +430,7 @@ when the registry, a vitest config or a setup file changed, since those can move
430
430
  commit, and in CI alongside the publish without blocking it. The price of caching is a cache that
431
431
  has to model each spec's full dependency closure correctly, and getting that wrong produces a stale
432
432
  PASS for a test that has since gone vacuous — exactly what the gate is there to prevent. Bad trade
433
- at 676 mutations.
433
+ at 678 mutations.
434
434
 
435
435
  **Decided 2026-10-03 (repo owner): keep the full run.** Measured at 128 mutations, the CI job for
436
436
  11.41.6 took **14 minutes**. The trigger to revisit is that wall time, not the mutation count —
@@ -501,9 +501,9 @@ exactly the environment where the answer matters.
501
501
 
502
502
  ### The cost is vitest's cold start, not the tests
503
503
 
504
- Worth knowing before optimising the wrong thing: the specs behind all 239 e2e mutations add up to
504
+ Worth knowing before optimising the wrong thing: the specs behind all 240 e2e mutations add up to
505
505
  **~40 seconds**. The step takes ~740s. The remaining ~700s is paying vitest's startup — process
506
- spawn, transform, module graph, mongod connect, DB create and drop — once per mutation, 676 times.
506
+ spawn, transform, module graph, mongod connect, DB create and drop — once per mutation, 678 times.
507
507
  That work is largely single-threaded I/O and barely scales with cores: the full registry measures
508
508
  **744s on a 12-core laptop and 777s on a 4-vCPU CI runner**.
509
509
 
package/FRAMEWORK-API.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @lenne.tech/nest-server — Framework API Reference
2
2
 
3
- > Auto-generated from source code as of 2026-11-19 (v12.6.14)
3
+ > Auto-generated from source code as of 2026-11-20 (v12.6.15)
4
4
  > File: `FRAMEWORK-API.md` — compact, machine-readable API surface for Claude Code
5
5
 
6
6
  ## CoreModule.forRoot()
@@ -1,3 +1,5 @@
1
1
  export declare function resolveBetterAuthCookiePrefix(basePath: string, env?: NodeJS.ProcessEnv): string;
2
2
  export declare function resolveBetterAuthSessionCookieName(basePath: string, env?: NodeJS.ProcessEnv): string;
3
+ export declare const DEFAULT_JWT_COOKIE_NAME = "lt-jwt-token";
4
+ export declare function resolveJwtCookieName(env?: NodeJS.ProcessEnv): string;
3
5
  export declare function detectCookiePrefixDrift(resolvedPrefix: string, programmaticOptionsAdvanced: unknown): null | string;
@@ -9,6 +9,11 @@ export function resolveBetterAuthCookiePrefix(basePath, env = process.env) {
9
9
  export function resolveBetterAuthSessionCookieName(basePath, env = process.env) {
10
10
  return `${resolveBetterAuthCookiePrefix(basePath, env)}.session_token`;
11
11
  }
12
+ export const DEFAULT_JWT_COOKIE_NAME = 'lt-jwt-token';
13
+ export function resolveJwtCookieName(env = process.env) {
14
+ const explicit = sanitizeCookiePrefix(typeof env.COOKIE_PREFIX === 'string' ? env.COOKIE_PREFIX : '');
15
+ return explicit ? `${explicit}-jwt-token` : DEFAULT_JWT_COOKIE_NAME;
16
+ }
12
17
  export function detectCookiePrefixDrift(resolvedPrefix, programmaticOptionsAdvanced) {
13
18
  if (!programmaticOptionsAdvanced || typeof programmaticOptionsAdvanced !== 'object')
14
19
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"better-auth-cookie-prefix.helper.js","sourceRoot":"","sources":["../../../../src/core/modules/better-auth/better-auth-cookie-prefix.helper.ts"],"names":[],"mappings":"AAqBA,SAAS,oBAAoB,CAAC,GAAW;IACvC,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;AACpD,CAAC;AAsBD,MAAM,UAAU,6BAA6B,CAAC,QAAgB,EAAE,MAAyB,OAAO,CAAC,GAAG;IAClG,MAAM,cAAc,GAAG,CAAC,QAAQ,IAAI,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACnF,MAAM,QAAQ,GAAG,oBAAoB,CAAC,OAAO,GAAG,CAAC,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACtG,OAAO,QAAQ,IAAI,cAAc,CAAC;AACpC,CAAC;AAOD,MAAM,UAAU,kCAAkC,CAAC,QAAgB,EAAE,MAAyB,OAAO,CAAC,GAAG;IACvG,OAAO,GAAG,6BAA6B,CAAC,QAAQ,EAAE,GAAG,CAAC,gBAAgB,CAAC;AACzE,CAAC;AAgBD,MAAM,UAAU,uBAAuB,CAAC,cAAsB,EAAE,2BAAoC;IAClG,IAAI,CAAC,2BAA2B,IAAI,OAAO,2BAA2B,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACjG,MAAM,kBAAkB,GAAI,2BAAuD,CAAC,YAAY,CAAC;IACjG,IAAI,OAAO,kBAAkB,KAAK,QAAQ,IAAI,kBAAkB,KAAK,cAAc;QAAE,OAAO,IAAI,CAAC;IACjG,OAAO,CACL,kCAAkC,kBAAkB,kCAAkC;QACtF,4BAA4B,cAAc,iDAAiD;QAC3F,2EAA2E,CAC5E,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"better-auth-cookie-prefix.helper.js","sourceRoot":"","sources":["../../../../src/core/modules/better-auth/better-auth-cookie-prefix.helper.ts"],"names":[],"mappings":"AAqBA,SAAS,oBAAoB,CAAC,GAAW;IACvC,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;AACpD,CAAC;AAsBD,MAAM,UAAU,6BAA6B,CAAC,QAAgB,EAAE,MAAyB,OAAO,CAAC,GAAG;IAClG,MAAM,cAAc,GAAG,CAAC,QAAQ,IAAI,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACnF,MAAM,QAAQ,GAAG,oBAAoB,CAAC,OAAO,GAAG,CAAC,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACtG,OAAO,QAAQ,IAAI,cAAc,CAAC;AACpC,CAAC;AAOD,MAAM,UAAU,kCAAkC,CAAC,QAAgB,EAAE,MAAyB,OAAO,CAAC,GAAG;IACvG,OAAO,GAAG,6BAA6B,CAAC,QAAQ,EAAE,GAAG,CAAC,gBAAgB,CAAC;AACzE,CAAC;AAGD,MAAM,CAAC,MAAM,uBAAuB,GAAG,cAAc,CAAC;AAWtD,MAAM,UAAU,oBAAoB,CAAC,MAAyB,OAAO,CAAC,GAAG;IACvE,MAAM,QAAQ,GAAG,oBAAoB,CAAC,OAAO,GAAG,CAAC,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACtG,OAAO,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,YAAY,CAAC,CAAC,CAAC,uBAAuB,CAAC;AACtE,CAAC;AAgBD,MAAM,UAAU,uBAAuB,CAAC,cAAsB,EAAE,2BAAoC;IAClG,IAAI,CAAC,2BAA2B,IAAI,OAAO,2BAA2B,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACjG,MAAM,kBAAkB,GAAI,2BAAuD,CAAC,YAAY,CAAC;IACjG,IAAI,OAAO,kBAAkB,KAAK,QAAQ,IAAI,kBAAkB,KAAK,cAAc;QAAE,OAAO,IAAI,CAAC;IACjG,OAAO,CACL,kCAAkC,kBAAkB,kCAAkC;QACtF,4BAA4B,cAAc,iDAAiD;QAC3F,2EAA2E,CAC5E,CAAC;AACJ,CAAC"}
@@ -10,6 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  var CoreBetterAuthMiddleware_1;
11
11
  import { Injectable, Logger } from '@nestjs/common';
12
12
  import { hasApiTokenCredential } from '../api-token/core-api-token.helpers.js';
13
+ import { resolveJwtCookieName } from './better-auth-cookie-prefix.helper.js';
13
14
  import { isLegacyJwt } from './core-better-auth-token.helper.js';
14
15
  import { CoreBetterAuthUserMapper } from './core-better-auth-user.mapper.js';
15
16
  import { convertExpressHeaders, extractSessionToken } from './core-better-auth-web.helper.js';
@@ -86,9 +87,10 @@ let CoreBetterAuthMiddleware = CoreBetterAuthMiddleware_1 = class CoreBetterAuth
86
87
  }
87
88
  if (!req.user && !req.headers.authorization && this.betterAuthService.isJwtEnabled()) {
88
89
  try {
89
- let jwtFromCookie = req.cookies?.['lt-jwt-token'];
90
+ const jwtCookieName = resolveJwtCookieName();
91
+ let jwtFromCookie = req.cookies?.[jwtCookieName];
90
92
  if (!jwtFromCookie && req.headers.cookie) {
91
- const match = req.headers.cookie.match(/(?:^|;\s*)lt-jwt-token=([^;]+)/);
93
+ const match = req.headers.cookie.match(new RegExp(`(?:^|;\\s*)${jwtCookieName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}=([^;]+)`));
92
94
  if (match) {
93
95
  jwtFromCookie = decodeURIComponent(match[1]);
94
96
  }
@@ -1 +1 @@
1
- {"version":3,"file":"core-better-auth.middleware.js","sourceRoot":"","sources":["../../../../src/core/modules/better-auth/core-better-auth.middleware.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAkB,MAAM,gBAAgB,CAAC;AAGpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAyB,wBAAwB,EAAc,MAAM,mCAAmC,CAAC;AAChH,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC9F,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AA+B/D,IAAM,wBAAwB,gCAA9B,MAAM,wBAAwB;IAIhB;IACA;IAJF,MAAM,GAAG,IAAI,MAAM,CAAC,0BAAwB,CAAC,IAAI,CAAC,CAAC;IAEpE,YACmB,iBAAwC,EACxC,UAAoC;QADpC,sBAAiB,GAAjB,iBAAiB,CAAuB;QACxC,eAAU,GAAV,UAAU,CAA0B;IACpD,CAAC;IAEJ,KAAK,CAAC,GAAG,CAAC,GAA0B,EAAE,IAAc,EAAE,I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AI,CAAC;YACd,CAAC;YAGD,MAAM,OAAO,GAAG,qBAAqB,CAAC,GAAG,CAAC,OAAwD,CAAC,CAAC;YAGpG,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;YAEnD,IAAI,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,MAAM,IAAI,QAAQ,EAAE,CAAC;gBACnE,OAAO,QAAyD,CAAC;YACnE,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC;YACnG,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF,CAAA;AAnPY,wBAAwB;IADpC,UAAU,EAAE;qCAK2B,qBAAqB;QAC5B,wBAAwB;GAL5C,wBAAwB,CAmPpC"}
1
+ {"version":3,"file":"core-better-auth.middleware.js","sourceRoot":"","sources":["../../../../src/core/modules/better-auth/core-better-auth.middleware.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAkB,MAAM,gBAAgB,CAAC;AAGpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAyB,wBAAwB,EAAc,MAAM,mCAAmC,CAAC;AAChH,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC9F,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AA+B/D,IAAM,wBAAwB,gCAA9B,MAAM,wBAAwB;IAIhB;IACA;I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AC;YAErG,IAAI,YAAY,EAAE,CAAC;gBAEjB,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;gBAEnF,IAAI,aAAa,EAAE,IAAI,IAAI,aAAa,EAAE,OAAO,EAAE,CAAC;oBAClD,OAAO,aAA8D,CAAC;gBACxE,CAAC;YACH,CAAC;YAGD,MAAM,GAAG,GAAG,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,CAAC;YAC5C,IAAI,CAAC,GAAG,EAAE,CAAC;gBACT,OAAO,IAAI,CAAC;YACd,CAAC;YAGD,MAAM,OAAO,GAAG,qBAAqB,CAAC,GAAG,CAAC,OAAwD,CAAC,CAAC;YAGpG,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;YAEnD,IAAI,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,MAAM,IAAI,QAAQ,EAAE,CAAC;gBACnE,OAAO,QAAyD,CAAC;YACnE,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC;YACnG,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF,CAAA;AAvPY,wBAAwB;IADpC,UAAU,EAAE;qCAK2B,qBAAqB;QAC5B,wBAAwB;GAL5C,wBAAwB,CAuPpC"}
@@ -0,0 +1,70 @@
1
+ # Migration Guide: 12.6.14 → 12.6.15
2
+
3
+ ## Overview
4
+
5
+ | Category | Details |
6
+ |---|---|
7
+ | **Breaking Changes** | None |
8
+ | **New Features** | None. `resolveJwtCookieName()` and `DEFAULT_JWT_COOKIE_NAME` name the JWT cookie |
9
+ | **Bugfixes** | With `COOKIE_PREFIX`, the API reads a JWT-mode frontend's JWT cookie under `<prefix>-jwt-token`, the name `@lenne.tech/nuxt-extensions` writes (§1) |
10
+ | **Security** | None |
11
+ | **Migration Effort** | Package update. Only projects that set `COOKIE_PREFIX` and run in JWT mode (`cookies: false`) notice a difference |
12
+
13
+ ## Quick Migration
14
+
15
+ ```bash
16
+ pnpm add @lenne.tech/nest-server@12.6.15
17
+ pnpm run update # nest-server-starter based projects
18
+ pnpm run build
19
+ pnpm test
20
+ ```
21
+
22
+ **Vendor mode**: run `/lt-dev:backend:update-nest-server-core` as usual.
23
+
24
+ ## 1. Bugfix: the JWT cookie follows `COOKIE_PREFIX`
25
+
26
+ **No action needed.** Keep `COOKIE_PREFIX` (API) and `NUXT_PUBLIC_COOKIE_PREFIX` (app) equal, as before.
27
+
28
+ In JWT mode the frontend keeps the Better-Auth JWT in a cookie as well as sending it as a bearer token. A request that
29
+ carries the cookie but no `Authorization` header is authenticated by `CoreBetterAuthMiddleware` from that cookie: a
30
+ server-side rendered page that forwards the browser's cookies, and a passkey request from the app.
31
+
32
+ `@lenne.tech/nuxt-extensions` names that cookie `<NUXT_PUBLIC_COOKIE_PREFIX>-jwt-token` when a prefix is set. Up to
33
+ 12.6.14 the API read `lt-jwt-token` only. With a prefix such a request was anonymous, and Better-Auth's plugin routes
34
+ (passkey registration, two-factor) answered `401`.
35
+
36
+ | `COOKIE_PREFIX` | JWT cookie read since 12.6.15 | Before |
37
+ |---|---|---|
38
+ | not set | `lt-jwt-token` | `lt-jwt-token` |
39
+ | `acme` | `acme-jwt-token` | `lt-jwt-token` |
40
+
41
+ The prefix is sanitised by the same rule as on the frontend (`[A-Za-z0-9._-]`). The base path does not enter the name,
42
+ unlike the session cookie (`<prefix>.session_token`, else `iam.session_token`). There is no fallback to `lt-jwt-token`
43
+ while `COOKIE_PREFIX` is set: the prefix keeps the apps on one host apart, and the session cookie does not fall back
44
+ either.
45
+
46
+ ## 2. Dependencies
47
+
48
+ A pnpm override lifts `i18next` to 26.4.4 under `@compodoc/compodoc` (GHSA-6jcc-5g8w-32mx, GHSA-5jr9-983r-c8x4). It is dev tooling of this repository (`pnpm run docs`) and does not reach consumers; nothing to do in a project.
49
+
50
+ ## Compatibility Notes
51
+
52
+ | Pattern | Status |
53
+ |---|---|
54
+ | No `COOKIE_PREFIX` | Unchanged |
55
+ | `COOKIE_PREFIX` with cookies (the default `cookies: true`) | Unchanged; the session cookie already followed the prefix |
56
+ | `COOKIE_PREFIX` with `cookies: false` and a matching `NUXT_PUBLIC_COOKIE_PREFIX` | Fixed: the JWT cookie is read |
57
+ | A frontend that sets `COOKIE_PREFIX` on the API but writes `lt-jwt-token` | No longer authenticated through the cookie. Set the same prefix on both sides |
58
+
59
+ ## Troubleshooting
60
+
61
+ | Symptom | Cause | Fix |
62
+ |---|---|---|
63
+ | Passkey or 2FA routes answer `401` in JWT mode with a cookie prefix | 12.6.14 or older read only `lt-jwt-token` | Update to 12.6.15 |
64
+ | Still `401` after the update | The API and the app use different prefixes | Set `COOKIE_PREFIX` and `NUXT_PUBLIC_COOKIE_PREFIX` to the same value |
65
+
66
+ ## Module Documentation
67
+
68
+ - `src/core/modules/better-auth/better-auth-cookie-prefix.helper.ts`: `resolveJwtCookieName()`, `resolveBetterAuthCookiePrefix()`
69
+ - Same fix on the current line: 12.11.2
70
+ - `migration-guides/11.26.1-to-11.26.2.md`, §1: `COOKIE_PREFIX` and the frontend pairing
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lenne.tech/nest-server",
3
- "version": "12.6.14",
3
+ "version": "12.6.15",
4
4
  "type": "module",
5
5
  "description": "Server framework in TypeScript on top of NestJS: GraphQL and REST APIs on MongoDB, PostgreSQL, MySQL or MariaDB, with authentication, field-level permissions, multi-tenancy, offline sync and an AI assistant.",
6
6
  "keywords": [
@@ -58,6 +58,23 @@ export function resolveBetterAuthSessionCookieName(basePath: string, env: NodeJS
58
58
  return `${resolveBetterAuthCookiePrefix(basePath, env)}.session_token`;
59
59
  }
60
60
 
61
+ /** The name of the JWT cookie without `COOKIE_PREFIX`, the one `@lenne.tech/nuxt-extensions` writes by default. */
62
+ export const DEFAULT_JWT_COOKIE_NAME = 'lt-jwt-token';
63
+
64
+ /**
65
+ * The cookie a JWT-mode frontend keeps the Better-Auth JWT in (12.6.15): `<COOKIE_PREFIX>-jwt-token` when `COOKIE_PREFIX`
66
+ * is set, otherwise `lt-jwt-token`. `@lenne.tech/nuxt-extensions` names it the same way from `NUXT_PUBLIC_COOKIE_PREFIX`,
67
+ * sanitised by the same rule. Unlike the session cookie, the basePath never enters the name.
68
+ *
69
+ * There is no fallback to `lt-jwt-token` while `COOKIE_PREFIX` is set: the prefix isolates the apps on one host, and
70
+ * the session cookie does not fall back either. Before 12.6.15 the API read `lt-jwt-token` only, so with a prefix
71
+ * every request without an `Authorization` header (SSR with forwarded cookies, a passkey request) was anonymous.
72
+ */
73
+ export function resolveJwtCookieName(env: NodeJS.ProcessEnv = process.env): string {
74
+ const explicit = sanitizeCookiePrefix(typeof env.COOKIE_PREFIX === 'string' ? env.COOKIE_PREFIX : '');
75
+ return explicit ? `${explicit}-jwt-token` : DEFAULT_JWT_COOKIE_NAME;
76
+ }
77
+
61
78
  /**
62
79
  * Detect a Better-Auth cookie-prefix drift between the value the NestJS layer
63
80
  * resolves (via {@link resolveBetterAuthCookiePrefix}) and a programmatic
@@ -2,6 +2,7 @@ import { Injectable, Logger, NestMiddleware } from '@nestjs/common';
2
2
  import { NextFunction, Request, Response } from 'express';
3
3
 
4
4
  import { hasApiTokenCredential } from '../api-token/core-api-token.helpers.js';
5
+ import { resolveJwtCookieName } from './better-auth-cookie-prefix.helper.js';
5
6
  import { isLegacyJwt } from './core-better-auth-token.helper.js';
6
7
  import { BetterAuthSessionUser, CoreBetterAuthUserMapper, MappedUser } from './core-better-auth-user.mapper.js';
7
8
  import { convertExpressHeaders, extractSessionToken } from './core-better-auth-web.helper.js';
@@ -142,14 +143,18 @@ export class CoreBetterAuthMiddleware implements NestMiddleware {
142
143
 
143
144
  // Strategy 2: Try JWT from cookie (for JWT mode when frontend stores JWT as cookie)
144
145
  // In JWT mode (cookies=false), the frontend may store the JWT in a cookie
145
- // (e.g., lt-jwt-token) instead of sending it as an Authorization header.
146
+ // (`lt-jwt-token`, `<COOKIE_PREFIX>-jwt-token` with a prefix) instead of sending it as an Authorization header.
146
147
  // This bridges the gap between cookie-based frontend storage and JWT verification.
147
148
  if (!req.user && !req.headers.authorization && this.betterAuthService.isJwtEnabled()) {
148
149
  try {
149
- // Try parsed cookies first, then raw header (cookie-parser may not have run yet)
150
- let jwtFromCookie = req.cookies?.['lt-jwt-token'];
150
+ // Try parsed cookies first, then raw header (cookie-parser may not have run yet). The name follows
151
+ // COOKIE_PREFIX like the frontend's (`<prefix>-jwt-token`, else `lt-jwt-token`; 12.6.15).
152
+ const jwtCookieName = resolveJwtCookieName();
153
+ let jwtFromCookie = req.cookies?.[jwtCookieName];
151
154
  if (!jwtFromCookie && req.headers.cookie) {
152
- const match = req.headers.cookie.match(/(?:^|;\s*)lt-jwt-token=([^;]+)/);
155
+ const match = req.headers.cookie.match(
156
+ new RegExp(`(?:^|;\\s*)${jwtCookieName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}=([^;]+)`),
157
+ );
153
158
  if (match) {
154
159
  jwtFromCookie = decodeURIComponent(match[1]);
155
160
  }