@lenne.tech/nuxt-extensions 4.0.0 → 4.0.2
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.
- package/CLAUDE.md +15 -0
- package/README.md +6 -0
- package/dist/module.d.mts +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +4 -1
- package/dist/runtime/lib/auth-state.d.ts +21 -5
- package/dist/runtime/lib/index.d.ts +1 -1
- package/dist/runtime/lib/index.js +1 -0
- package/package.json +10 -10
package/CLAUDE.md
CHANGED
|
@@ -106,6 +106,21 @@ export default defineNuxtConfig({
|
|
|
106
106
|
|
|
107
107
|
The API base URL is resolved at runtime from `NUXT_PUBLIC_API_URL` (client + SSR fallback) and the optional `NUXT_API_URL` (SSR-only, e.g. for internal cluster addresses). `NUXT_API_URL` is never promoted into the public bundle.
|
|
108
108
|
|
|
109
|
+
**URLs that end up in HTML use `buildLtPublicApiUrl()`, never `buildLtApiUrl()`.** During SSR
|
|
110
|
+
`buildLtApiUrl()` and `getLtApiBase()` return `NUXT_API_URL`: they build the URLs the server
|
|
111
|
+
requests itself. Rendered into `src`, `href`, `srcset`, a CSS `url()` or a `useState` value, that
|
|
112
|
+
internal address (`http://api:3000`) reaches every visitor, and images and downloads break in
|
|
113
|
+
production only, where it differs from the public one. A project with a vendored core did exactly
|
|
114
|
+
that in November 2026. `buildLtPublicApiUrl()` (auto-imported, also in `/lib`) and the file links
|
|
115
|
+
of `useLtFile()` use the browser's address during SSR too.
|
|
116
|
+
|
|
117
|
+
- **Nothing this module renders or stores in state may use the request URL.** Error texts count:
|
|
118
|
+
Node's fetch names the request URL in some errors, so `useLtAiStatus()` stores fixed texts, never
|
|
119
|
+
`error.message`.
|
|
120
|
+
- **Guards:** `test/ssr-api-url-in-html.test.ts` renders in the server scope with an internal and a
|
|
121
|
+
public address (part of `check`), and `check:consumer` renders a page on the built Nitro server
|
|
122
|
+
with `NUXT_API_URL` set (part of `release`). Both fail as soon as the internal host is in the HTML.
|
|
123
|
+
|
|
109
124
|
## Authentication (Better Auth)
|
|
110
125
|
|
|
111
126
|
- SSR-safe session management via `useLtAuth()`
|
package/README.md
CHANGED
|
@@ -147,6 +147,12 @@ All requests go to `/api/{path}` — the Vite dev proxy forwards them to the bac
|
|
|
147
147
|
|
|
148
148
|
> **Security:** `NUXT_API_URL` is never exposed to the client bundle. It stays in `runtimeConfig.apiUrl` (server only). This is important when using internal network addresses like `http://api.svc.cluster.local`.
|
|
149
149
|
|
|
150
|
+
> **URLs that end up in HTML: `buildLtPublicApiUrl()`, never `buildLtApiUrl()`.** During SSR `buildLtApiUrl()` (and `getLtApiBase()`) return `NUXT_API_URL`, because they build the URLs the server requests itself. Rendered into a `src`, `href`, `srcset`, a CSS `url()` or a `useState` value, that internal address reaches every visitor's HTML, and images and downloads break in production only, where it differs from the public one. `buildLtPublicApiUrl()` (auto-imported, also exported from `/lib`) and the file links of `useLtFile()` use the browser's address during SSR too:
|
|
151
|
+
>
|
|
152
|
+
> ```vue
|
|
153
|
+
> <img :src="buildLtPublicApiUrl(`/users/${user.id}/avatar`)" alt="">
|
|
154
|
+
> ```
|
|
155
|
+
|
|
150
156
|
### Deployment Scenarios
|
|
151
157
|
|
|
152
158
|
**Local development** — Frontend and backend on different ports, proxy ensures same-origin cookies:
|
package/dist/module.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import { LtExtensionsModuleOptions } from '../dist/runtime/types/index.js';
|
|
|
3
3
|
export * from '../dist/runtime/types/index.js';
|
|
4
4
|
|
|
5
5
|
declare const name = "@lenne.tech/nuxt-extensions";
|
|
6
|
-
declare const version = "4.0.
|
|
6
|
+
declare const version = "4.0.2";
|
|
7
7
|
declare const configKey = "ltExtensions";
|
|
8
8
|
declare const DEFAULT_LT_AUTH_STATE_COOKIE = "lt-auth-state";
|
|
9
9
|
declare const DEFAULT_LT_JWT_TOKEN_COOKIE = "lt-jwt-token";
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { pathToFileURL } from 'node:url';
|
|
|
3
3
|
import { SECURITY_TXT_DEFAULT_VALID_DAYS, SECURITY_TXT_DEFAULT_LANGUAGES, SECURITY_TXT_DEFAULT_CONTACT, SECURITY_TXT_PATH } from '../dist/runtime/server/lib/security-txt.js';
|
|
4
4
|
|
|
5
5
|
const name = "@lenne.tech/nuxt-extensions";
|
|
6
|
-
const version = "4.0.
|
|
6
|
+
const version = "4.0.2";
|
|
7
7
|
const configKey = "ltExtensions";
|
|
8
8
|
const DEFAULT_LT_AUTH_STATE_COOKIE = "lt-auth-state";
|
|
9
9
|
const DEFAULT_LT_JWT_TOKEN_COOKIE = "lt-jwt-token";
|
|
@@ -201,6 +201,9 @@ const module$1 = defineNuxtModule({
|
|
|
201
201
|
{ name: "getLtApiBase", from: resolve("./runtime/lib/auth-state") },
|
|
202
202
|
{ name: "getLtAuthCookieNames", from: resolve("./runtime/lib/auth-state") },
|
|
203
203
|
{ name: "buildLtApiUrl", from: resolve("./runtime/lib/auth-state") },
|
|
204
|
+
// The URL for HTML (`src`, `href`): buildLtApiUrl is for requests and renders the server-only
|
|
205
|
+
// NUXT_API_URL during SSR. Auto-imported so the right one is as close at hand as the wrong one.
|
|
206
|
+
{ name: "buildLtPublicApiUrl", from: resolve("./runtime/lib/auth-state") },
|
|
204
207
|
{ name: "isLocalDevApiProxy", from: resolve("./runtime/lib/auth-state") },
|
|
205
208
|
{ name: "attemptLtJwtSwitch", from: resolve("./runtime/lib/auth-state") },
|
|
206
209
|
{ name: "isLtAuthenticated", from: resolve("./runtime/lib/auth-state") },
|
|
@@ -186,6 +186,14 @@ export declare function warnMissingLtApiUrl(scope: 'client' | 'server'): void;
|
|
|
186
186
|
/**
|
|
187
187
|
* Build a full API URL for a given path, handling SSR, proxy, and direct modes.
|
|
188
188
|
*
|
|
189
|
+
* **For requests only, never for a URL that ends up in HTML.** During SSR this returns the
|
|
190
|
+
* server-only `NUXT_API_URL`, an internal address such as `http://api:3000`. Anything rendered with
|
|
191
|
+
* it (`src`, `href`, `srcset`, a CSS `url()`, a value in `useState` or another part of the SSR
|
|
192
|
+
* payload) ships that address to every visitor, whose browser cannot reach it: images and
|
|
193
|
+
* downloads break in production only, where the internal address differs from the public one. For
|
|
194
|
+
* links and images use {@link buildLtPublicApiUrl} or `useLtFile()`. This function is for requests
|
|
195
|
+
* the code makes itself (`fetch`, `$fetch`, `ltAuthFetch`).
|
|
196
|
+
*
|
|
189
197
|
* ## Resolution Strategy
|
|
190
198
|
*
|
|
191
199
|
* All environment variables are resolved **at runtime** by Nuxt's built-in
|
|
@@ -225,11 +233,16 @@ export declare function buildLtApiUrl(path: string): string;
|
|
|
225
233
|
/**
|
|
226
234
|
* The URL the browser uses for an API path, built the same way during SSR.
|
|
227
235
|
*
|
|
228
|
-
*
|
|
229
|
-
* `
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
236
|
+
* Use it for every API URL that ends up in HTML: `src`, `href`, `srcset`, avatars, images,
|
|
237
|
+
* downloads, a CSS `url()`, or a value stored in `useState` (the SSR payload is part of the HTML).
|
|
238
|
+
* {@link buildLtApiUrl} would put the server-only `NUXT_API_URL` (an internal cluster address
|
|
239
|
+
* such as `http://api:3000`) into the HTML during SSR, and behind the dev proxy the server and the
|
|
240
|
+
* browser would render different strings, a hydration mismatch. File links of `useLtFile()` use
|
|
241
|
+
* this already. Requests the server makes itself keep using {@link buildLtApiUrl}.
|
|
242
|
+
*
|
|
243
|
+
* ```vue
|
|
244
|
+
* <img :src="buildLtPublicApiUrl(`/users/${user.id}/avatar`)" alt="">
|
|
245
|
+
* ```
|
|
233
246
|
*
|
|
234
247
|
* `/api` + path while the dev proxy is on, otherwise `NUXT_PUBLIC_API_URL` (or `auth.baseURL`) +
|
|
235
248
|
* path; relative (with the one-shot warning) when neither is configured.
|
|
@@ -309,6 +322,9 @@ export declare function setLtAuthMode(mode: LtAuthMode): void;
|
|
|
309
322
|
* - **Direct mode** (proxy disabled or not set): Returns `{baseURL}{basePath}`
|
|
310
323
|
* (e.g., `https://api.example.com/iam`) for direct backend calls.
|
|
311
324
|
*
|
|
325
|
+
* For requests only: during SSR it holds the server-only `NUXT_API_URL`, so it must never be
|
|
326
|
+
* rendered into HTML (see {@link buildLtApiUrl}).
|
|
327
|
+
*
|
|
312
328
|
* @param basePath - The auth API base path. If not provided, reads from runtime config (default: '/iam')
|
|
313
329
|
*/
|
|
314
330
|
export declare function getLtApiBase(basePath?: string): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { attemptLtJwtSwitch, clearLtAuthCookies, createLtAuthFetch, getLtApiBase, getLtAuthCookieNames, getLtAuthMode, getLtJwtToken, isLtAuthenticated, isLtJwtShaped, LT_AUTH_STATE_COOKIE_DEFAULT, LT_JWT_TOKEN_COOKIE_DEFAULT, ltAuthFetch, setLtAuthMode, setLtJwtToken, } from './auth-state.js';
|
|
1
|
+
export { attemptLtJwtSwitch, buildLtPublicApiUrl, clearLtAuthCookies, createLtAuthFetch, getLtApiBase, getLtAuthCookieNames, getLtAuthMode, getLtJwtToken, isLtAuthenticated, isLtJwtShaped, LT_AUTH_STATE_COOKIE_DEFAULT, LT_JWT_TOKEN_COOKIE_DEFAULT, ltAuthFetch, setLtAuthMode, setLtJwtToken, } from './auth-state.js';
|
|
2
2
|
export { clearLtAuthPluginRegistry, createLtAuthClient, getOrCreateLtAuthClient, getLtAuthPluginRegistry, registerLtAuthPlugins, resetLtAuthClientSingleton, type LtAuthClient, } from './auth-client.js';
|
|
3
3
|
export { buildLtAiUrl, getLtAiBasePath, ltAiRequest, ltAiResponseError, parseLtAiSseStream } from './ai.js';
|
|
4
4
|
export { buildLtSyncUrl, flushLtSyncBeforeSignOut, getLtSyncBasePath, ltSyncObjectId, ltSyncUuidV7 } from './sync.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lenne.tech/nuxt-extensions",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "Reusable Nuxt 4 composables, components, and Better-Auth integration for lenne.tech projects",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -110,25 +110,25 @@
|
|
|
110
110
|
}
|
|
111
111
|
},
|
|
112
112
|
"devDependencies": {
|
|
113
|
-
"@better-auth/passkey": "1.7.
|
|
113
|
+
"@better-auth/passkey": "1.7.19",
|
|
114
114
|
"@nuxt/module-builder": "1.0.3",
|
|
115
115
|
"@nuxt/schema": "4.6.4",
|
|
116
116
|
"@nuxt/ui": "4.12.0",
|
|
117
|
-
"@playwright/test": "1.
|
|
117
|
+
"@playwright/test": "1.65.0",
|
|
118
118
|
"@types/node": "26.6.6",
|
|
119
119
|
"@vitest/coverage-v8": "5.1.0",
|
|
120
|
-
"@vue/server-renderer": "3.5.
|
|
121
|
-
"better-auth": "1.7.
|
|
120
|
+
"@vue/server-renderer": "3.5.45",
|
|
121
|
+
"better-auth": "1.7.19",
|
|
122
122
|
"cross-spawn": "7.0.6",
|
|
123
|
-
"fake-indexeddb": "6.2.
|
|
123
|
+
"fake-indexeddb": "6.2.8",
|
|
124
124
|
"happy-dom": "21.0.4",
|
|
125
125
|
"nuxt": "4.6.4",
|
|
126
|
-
"oxfmt": "0.
|
|
127
|
-
"oxlint": "1.
|
|
128
|
-
"oxlint-tsgolint": "7.0.
|
|
126
|
+
"oxfmt": "0.78.0",
|
|
127
|
+
"oxlint": "1.93.0",
|
|
128
|
+
"oxlint-tsgolint": "7.0.2006",
|
|
129
129
|
"reka-ui": "2.11.0",
|
|
130
130
|
"semver": "7.8.6",
|
|
131
|
-
"tailwindcss": "4.3.
|
|
131
|
+
"tailwindcss": "4.3.5",
|
|
132
132
|
"tus-js-client": "4.3.1",
|
|
133
133
|
"typescript": "5.9.3",
|
|
134
134
|
"vitest": "5.1.0",
|