@helloleo/plugins 0.2.0-beta.5 → 0.2.0-beta.6
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/dist/index.js
CHANGED
|
@@ -25629,6 +25629,7 @@ export interface SessionUser {
|
|
|
25629
25629
|
}
|
|
25630
25630
|
|
|
25631
25631
|
export async function getUser(): Promise<SessionUser | null> {
|
|
25632
|
+
if (typeof window === 'undefined') return null
|
|
25632
25633
|
const res = await fetch('/api/auth/me')
|
|
25633
25634
|
if (!res.ok) return null
|
|
25634
25635
|
const data = (await res.json()) as { user: SessionUser | null }
|
|
@@ -30,13 +30,7 @@ TanStack Start offers two ways to run server-side code:
|
|
|
30
30
|
- [Server routes](https://tanstack.com/start/latest/docs/framework/react/guide/server-routes) — files under `src/routes/api/` that export HTTP handlers.
|
|
31
31
|
- [Server functions](https://tanstack.com/start/latest/docs/framework/react/guide/server-functions) — `createServerFn()` calls colocated with components.
|
|
32
32
|
|
|
33
|
-
Prefer API routes. Create them under `src/routes/api/` following the same
|
|
34
|
-
convention as `src/routes/api/health.ts` (one handler per HTTP method under
|
|
35
|
-
`server.handlers`, returning `Response.json()`). This is more scalable and
|
|
36
|
-
gives the user visually readable endpoints (`/api/todos`, `/api/todos/:id`)
|
|
37
|
-
they can recognize in the network monitor. Server functions are served from
|
|
38
|
-
generated URLs that read as random gibberish, which makes requests hard to
|
|
39
|
-
identify and debug.
|
|
33
|
+
Prefer API routes. Create them under `src/routes/api/` following the same convention as `src/routes/api/health.ts` (one handler per HTTP method under `server.handlers`, returning `Response.json()`). This is more scalable and gives the user visually readable endpoints (`/api/todos`, `/api/todos/:id`) they can recognize in the network monitor. Server functions are served from generated URLs that read as random gibberish, which makes requests hard to identify and debug.
|
|
40
34
|
|
|
41
35
|
## Authenticated routes
|
|
42
36
|
|
package/package.json
CHANGED
|
@@ -30,13 +30,7 @@ TanStack Start offers two ways to run server-side code:
|
|
|
30
30
|
- [Server routes](https://tanstack.com/start/latest/docs/framework/react/guide/server-routes) — files under `src/routes/api/` that export HTTP handlers.
|
|
31
31
|
- [Server functions](https://tanstack.com/start/latest/docs/framework/react/guide/server-functions) — `createServerFn()` calls colocated with components.
|
|
32
32
|
|
|
33
|
-
Prefer API routes. Create them under `src/routes/api/` following the same
|
|
34
|
-
convention as `src/routes/api/health.ts` (one handler per HTTP method under
|
|
35
|
-
`server.handlers`, returning `Response.json()`). This is more scalable and
|
|
36
|
-
gives the user visually readable endpoints (`/api/todos`, `/api/todos/:id`)
|
|
37
|
-
they can recognize in the network monitor. Server functions are served from
|
|
38
|
-
generated URLs that read as random gibberish, which makes requests hard to
|
|
39
|
-
identify and debug.
|
|
33
|
+
Prefer API routes. Create them under `src/routes/api/` following the same convention as `src/routes/api/health.ts` (one handler per HTTP method under `server.handlers`, returning `Response.json()`). This is more scalable and gives the user visually readable endpoints (`/api/todos`, `/api/todos/:id`) they can recognize in the network monitor. Server functions are served from generated URLs that read as random gibberish, which makes requests hard to identify and debug.
|
|
40
34
|
|
|
41
35
|
## Authenticated routes
|
|
42
36
|
|
|
@@ -213,16 +213,6 @@ function isPrivateHost(hostname: string): boolean {
|
|
|
213
213
|
return base !== null && hosts[base].private;
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
// leo-core's nginx preview gate returns a static 403 page (see
|
|
217
|
-
// _PROXY_CONF_TMPL in sandbox/preview.py) when neither ?auth=<token>, the
|
|
218
|
-
// leo_auth_* cookie, nor the LeoInspect UA match. Recognize that exact page
|
|
219
|
-
// so a gated preview doesn't read as an app-level failure.
|
|
220
|
-
function isPreviewGate403(status: number, body: string): boolean {
|
|
221
|
-
return (
|
|
222
|
-
status === 403 && body.includes("403 Forbidden") && body.includes("nginx/")
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
216
|
function hasHeader(headers: Record<string, string>, name: string): boolean {
|
|
227
217
|
const target = name.toLowerCase();
|
|
228
218
|
for (const key of Object.keys(headers)) {
|
|
@@ -328,6 +328,7 @@ export interface SessionUser {
|
|
|
328
328
|
}
|
|
329
329
|
|
|
330
330
|
export async function getUser(): Promise<SessionUser | null> {
|
|
331
|
+
if (typeof window === 'undefined') return null
|
|
331
332
|
const res = await fetch('/api/auth/me')
|
|
332
333
|
if (!res.ok) return null
|
|
333
334
|
const data = (await res.json()) as { user: SessionUser | null }
|