Skip to content

feat: guest middleware - #26

Merged
cobraprojects merged 3 commits into
mainfrom
feat-guest-middleware
May 7, 2026
Merged

feat: guest middleware#26
cobraprojects merged 3 commits into
mainfrom
feat-guest-middleware

Conversation

@cobraprojects

@cobraprojects cobraprojects commented May 7, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Guest-only route protection added: authenticated users are redirected away from auth pages (login, register, forgot-password, reset-password) to /admin across Next.js, Nuxt, and SvelteKit.
    • Client-side auth now refreshes after successful login/registration/password reset to sync session state before redirecting.
  • Documentation

    • Added guidance and examples (Next.js, Nuxt, SvelteKit) on calling refreshUser() after auth actions.
  • Bug Fixes

    • Fixed various import/path issues affecting Nuxt auth pages and API routes.

@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@cobraprojects has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 41 minutes and 38 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c9e1ce05-32a0-47de-a5c1-a80fab2304e0

📥 Commits

Reviewing files that changed from the base of the PR and between 9eef907 and 1203b73.

📒 Files selected for processing (1)
  • apps/docs/docs/auth/current-auth-client.md
📝 Walkthrough

Walkthrough

This PR adds guest-only route protection across Next/Nuxt/SvelteKit, a Next request-scoped AsyncLocalStorage context, client-side auth refresh after login, Nuxt shared schema/type relocations, CLI-generated model-registry type emission, and updates tests and documentation.

Changes

Guest-Only Route Protection

Layer / File(s) Summary
Route Matching & Types
packages/adapter-next/src/server.ts, packages/adapter-nuxt/src/runtime/server/protection.ts, packages/adapter-sveltekit/src/server.ts
Core route matcher types (RouteMatcher), GuestOnlyOptions config, and pathname normalization/matching helpers supporting exact strings, regex, predicates, and /* wildcard patterns.
Next.js Request Context & Runtime
packages/adapter-next/src/request-context.ts, packages/adapter-next/src/runtime.ts
AsyncLocalStorage-backed request context (NextRequestLike), getCurrentNextRequest, runWithNextRequest; runtime prefers request-context cookies/headers and re-exports runner/types.
Next.js Proxy Handler
apps/blog-next/proxy.ts
Exports a guestOnly proxy configured for /login, /register, /forgot-password, /reset-password redirecting authenticated users to /admin.
Nuxt Server Protection & Shims
packages/adapter-nuxt/src/runtime/server/protection.*, packages/adapter-nuxt/src/runtime/shims.d.ts, packages/adapter-nuxt/src/module.ts, packages/adapter-nuxt/package.json
Nuxt guestOnly middleware implementation, type shims for route middleware, module wiring to push generated model-registry type reference on prepare:types, and ./server export mapping.
SvelteKit Handle Hook
packages/adapter-sveltekit/src/server.ts, apps/blog-sveltekit/src/hooks.server.ts
SvelteKit guestOnly handle and route-matching internals; app hooks use guestOnly to redirect authenticated users from guest-only routes.
Tests & Integration
packages/adapter-next/tests/server.test.ts, packages/adapter-nuxt/tests/protection.test.ts, packages/adapter-sveltekit/tests/server.test.ts, tests/example-app-auth-flow.mjs
Tests added/updated to verify redirect for authenticated users, pass-through for guests, wildcard/regex matching, and integration redirect assertions.

Auth State Refresh After Login

Layer / File(s) Summary
Client Library Fix
packages/auth/src/client-runtime.ts
fetchCurrentUser now invokes configured fetchImpl with this bound to globalThis.
Next.js Login Page
apps/blog-next/app/login/page.tsx
Imports useAuth() and calls auth.refreshUser() after successful /api/login before router.replace(redirectTo); failures are logged and do not block redirect.
Documentation & Examples
apps/docs/docs/auth/current-auth-client.md, apps/docs/docs/forms/framework-integration.md, apps/docs/docs/forms/server-validation.md
Adds guidance and multi-framework examples (Next/Nuxt/SvelteKit) that call refreshUser() after login/register and before navigation.
Tests
packages/auth/tests/package.test.ts
Adds test coverage validating fetchCurrentUser when fetch is a global function with this === globalThis expectation.

Nuxt Migration to Shared Schemas and Type Paths

Layer / File(s) Summary
Schema Path Migration
apps/blog-nuxt/app/pages/*.vue, apps/blog-nuxt/server/api/*.post.ts
Auth form schema imports switched from local ~/lib/schemas/auth to shared #shared/schemas/auth.
Type Import Path Corrections
apps/blog-nuxt/app/pages/...
Adjusted relative imports for server-side typed data (AdminPostData, AdminPostsData, CategoryArchiveData, etc.).
ESLint & Model Declaration Cleanup
apps/blog-nuxt/package.json, apps/blog-nuxt/server/holo-models.d.ts
Lint script targets updated; removed hand-authored Holo model type declarations (now emitted by CLI).

Model Registry Generation and CLI Updates

Layer / File(s) Summary
Shared CLI Types
packages/cli/src/project/shared.ts
Extend model reference definition with table.tableName, require prunable, add optional exportName, and define GENERATED_MODEL_TYPES_PATH.
Discovery & Registry
packages/cli/src/project/discovery.ts, packages/cli/src/project/registry.ts
Switch to resolveNamedExportEntry and capture tableName/prunable/exportName; add renderGeneratedModelTypes and write model-registry.d.ts.
Scaffold & Prepare
packages/cli/src/project/scaffold/framework.ts, packages/cli/src/dev.ts
Ensure generated schema placeholder and model types are created during scaffold/prepare; Nuxt scaffold app path adjusted.
Tests
packages/cli/tests/cli.test.ts, packages/adapter-nuxt/tests/module.test.ts, packages/adapter-nuxt/tests/setup.test.ts
Tests updated to assert generated model-registry.d.ts presence, Nuxt app file location, and prepare:types references.

Next.js Request Context Infrastructure

Layer / File(s) Summary
Async-Local Request Storage
packages/adapter-next/src/request-context.ts
Adds AsyncLocalStorage-backed NextRequestLike context, getCurrentNextRequest(), and runWithNextRequest.
Runtime Integration
packages/adapter-next/src/runtime.ts
Auth request accessor resolution prefers getCurrentNextRequest() when present and falls back to Next’s cookies()/headers() stores; re-exports request-context runner/types.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Client as Browser
    participant Server as Auth Server
    participant Store as Session Store

    User->>Client: Click Login
    Client->>Server: POST /api/login (credentials)
    Server->>Store: Validate & create session
    Store-->>Server: Session token
    Server-->>Client: 200 OK + Set-Cookie
    
    Note over Client: client calls refreshUser()
    Client->>Server: GET /api/auth/current-user
    Server->>Store: Fetch session user
    Store-->>Server: User data
    Server-->>Client: User profile
    Client->>Client: update auth state
    Client->>Client: router.replace(redirectTo)
Loading
sequenceDiagram
    actor Visitor
    participant Browser
    participant Middleware as Guest-Only Middleware
    participant AuthProvider as Auth Provider

    Visitor->>Browser: Navigate to /login
    Browser->>Middleware: route request
    Middleware->>AuthProvider: check auth
    AuthProvider-->>Middleware: { authenticated: true/false }

    alt authenticated
        Middleware-->>Browser: 303 Redirect to /admin
    else
        Middleware-->>Browser: continue to /login
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

  • cobraprojects/holo-js#24: Modifies auth refresh after login in multiple client frameworks using the same refreshUser() pattern.
  • cobraprojects/holo-js#19: Adds auth composable/runtime pieces that this PR integrates (useAuth, refresh helpers, adapter auth surface).
  • cobraprojects/holo-js#16: Related CLI/schema generation and model-registry generation changes.

Poem

🐰 I hopped through routes both near and wide,

Guests now nudged gently to the admin side,
After login I brushed my whiskers anew,
Called refreshUser, then onward I flew—
Generated types snug, the registry in stride.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: guest middleware' accurately summarizes the main change, which is the implementation of guest-only middleware across multiple framework adapters (Next.js, Nuxt, SvelteKit).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat-guest-middleware

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/adapter-nuxt/src/module.ts (1)

381-387: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

model-registry.d.ts referenced unconditionally may cause TypeScript errors on cold-start.

model-registry.d.ts is generated by the Holo CLI, not by this module. When developers run nuxt dev / nuxt prepare directly on a fresh project (before the CLI has been executed), the file won't exist and TypeScript will fail to resolve the /// <reference path="..." /> directive with "File not found."

Since mkdir and writeFile are already imported, the simplest fix is to write an empty placeholder during module setup if the file is absent:

🛡️ Proposed fix — create an empty placeholder if the file is missing
+    const modelRegistryDir = resolve(rootDir, '.holo-js/generated')
     const modelRegistryTypesPath = resolve(rootDir, '.holo-js/generated/model-registry.d.ts')
+    try {
+      await mkdir(modelRegistryDir, { recursive: true })
+      await writeFile(modelRegistryTypesPath, '', { flag: 'ax' }) // create only if absent
+    } catch {
+      // file already exists — CLI will overwrite with real content
+    }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/adapter-nuxt/src/module.ts` around lines 381 - 387, The
prepare:types hook currently unconditionally references modelRegistryTypesPath
which can cause TypeScript "File not found" on cold-start; adjust the module
setup so when opts._holoTypesRegistered is being set and before pushing the
reference in nuxt.hook('prepare:types') check whether modelRegistryTypesPath
exists and if not create its parent directory (use mkdir) and write an empty
placeholder file (use writeFile) so the /// <reference path="..."> resolves even
before the Holo CLI generates it; keep the same opts._holoTypesRegistered guard
and only create the placeholder when the file is missing.
🧹 Nitpick comments (1)
packages/cli/src/project/registry.ts (1)

141-174: ⚡ Quick win

Unused type imports in renderGeneratedModelTypes when models is empty.

When models is an empty array, the generated .d.ts file still unconditionally emits:

import type { EmptyScopeMap, GeneratedSchemaTable, ModelReference } from '@holo-js/db'

but none of these types are referenced (no aliases are produced). This departs from the pattern used by sibling renderers — renderGeneratedQueueTypes, renderGeneratedBroadcastTypes, and renderGeneratedEventTypes all guard their type imports with a conditional. TypeScript's verbatimModuleSyntax / isolatedDeclarations or a linting rule such as @typescript-eslint/no-unused-vars applied to the generated output could surface errors.

♻️ Suggested fix — guard type import on non-empty models
 export function renderGeneratedModelTypes(models: readonly GeneratedModelRegistryEntry[]): string {
   const aliases = models.map((entry, index) => {
     return `type HoloModel${index} = ModelReference<GeneratedSchemaTable<${JSON.stringify(entry.tableName)}>, EmptyScopeMap>`
   })
   const registryEntries = models.map((entry, index) => {
     return `    readonly ${JSON.stringify(entry.name)}: HoloModel${index}`
   })
   const registeredModelsDeclaration = registryEntries.length > 0
     ? [
         '  interface RegisteredModels {',
         ...registryEntries,
         '  }',
       ]
     : [
         '  // eslint-disable-next-line `@typescript-eslint/no-empty-object-type`',
         '  interface RegisteredModels {}',
       ]

   return [
     '// Generated by holo prepare. Do not edit.',
     '',
     'import \'./schema.generated\'',
+    ...(models.length > 0
+      ? ['import type { EmptyScopeMap, GeneratedSchemaTable, ModelReference } from \'@holo-js/db\'']
+      : []),
-    'import type { EmptyScopeMap, GeneratedSchemaTable, ModelReference } from \'@holo-js/db\'',
     '',
-    ...aliases,
-    '',
+    ...(aliases.length > 0 ? [...aliases, ''] : []),
     'declare module \'@holo-js/db\' {',
     ...registeredModelsDeclaration,
     '}',
     '',
     'export {}',
     '',
   ].join('\n')
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/project/registry.ts` around lines 141 - 174, The generated
.d.ts always includes the type import even when models is empty; update
renderGeneratedModelTypes to only emit the line "import type { EmptyScopeMap,
GeneratedSchemaTable, ModelReference } from '@holo-js/db'" when models.length >
0 (i.e., when aliases will be produced). Locate renderGeneratedModelTypes and
wrap or conditionally add that import in the returned array/build so the import
is omitted for empty models, matching the conditional pattern used in
renderGeneratedQueueTypes/renderGeneratedBroadcastTypes/renderGeneratedEventTypes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/docs/docs/auth/current-auth-client.md`:
- Around line 56-59: The example should not let refreshUser() rejection block
navigation: wrap the auth.refreshUser() call in a try-catch (or handle its
promise rejection) so that regardless of refreshUser() failing you still call
router.replace(submission.data.redirectTo); locate the block that checks
submission?.ok and submission.data?.redirectTo and update it to attempt
auth.refreshUser() inside try { await auth.refreshUser() } catch (e) { /*
optional log */ } then call router.replace(submission.data.redirectTo)
outside/after the catch to ensure redirect always occurs.

In `@packages/adapter-next/src/server.ts`:
- Around line 45-47: The RegExp route check using route.test(normalizedPathname)
can produce flaky results for stateful regexes with /g or /y because lastIndex
is preserved; before calling route.test(normalizedPathname) inside the route
instanceof RegExp branch, reset route.lastIndex = 0 so each test starts from the
beginning (locate the route instanceof RegExp check around the RegExp.test call
and set lastIndex to 0 just prior to invoking test).

In `@packages/adapter-nuxt/src/runtime/server/protection.ts`:
- Around line 37-39: The RegExp matcher can be stateful because test() advances
lastIndex for /g or /y flags; before using the existing `route` RegExp to match
`normalizedPathname` (the branch where `if (route instanceof RegExp)`), reset
`route.lastIndex = 0` and then call `route.test(normalizedPathname)` so repeated
calls using the same RegExp instance do not yield intermittent false negatives;
update the branch handling the `route` RegExp to reset lastIndex prior to
testing.

In `@packages/adapter-sveltekit/src/server.ts`:
- Around line 92-104: The guestOnly handler may cause self-redirect loops when
options.redirectTo resolves to the same path (or when routes are broad); update
the guestOnly function to compute the resolved redirect URL (new
URL(options.redirectTo, event.url)) and compare its pathname (and optionally
search/hash) against event.url.pathname (and search/hash) and, if they match,
skip the redirect and return resolve(event) instead; keep using matchesRoutes,
auth({ guard: options.guard }) and Response.redirect as before, but only call
Response.redirect when the resolved redirect target is different from the
current request URL.
- Around line 53-55: The RegExp matcher can carry a persistent lastIndex for
global or sticky flags causing intermittent failures; before calling
route.test(normalizedPathname) reset the regex's lastIndex (e.g., set
route.lastIndex = 0) so tests are consistent; update the check in the
route-matching logic where the symbols route and normalizedPathname are used and
apply the same change to the equivalent matcher locations in adapter-next
(packages/adapter-next/src/server.ts) and adapter-nuxt
(packages/adapter-nuxt/src/runtime/server/protection.ts).

---

Outside diff comments:
In `@packages/adapter-nuxt/src/module.ts`:
- Around line 381-387: The prepare:types hook currently unconditionally
references modelRegistryTypesPath which can cause TypeScript "File not found" on
cold-start; adjust the module setup so when opts._holoTypesRegistered is being
set and before pushing the reference in nuxt.hook('prepare:types') check whether
modelRegistryTypesPath exists and if not create its parent directory (use mkdir)
and write an empty placeholder file (use writeFile) so the /// <reference
path="..."> resolves even before the Holo CLI generates it; keep the same
opts._holoTypesRegistered guard and only create the placeholder when the file is
missing.

---

Nitpick comments:
In `@packages/cli/src/project/registry.ts`:
- Around line 141-174: The generated .d.ts always includes the type import even
when models is empty; update renderGeneratedModelTypes to only emit the line
"import type { EmptyScopeMap, GeneratedSchemaTable, ModelReference } from
'@holo-js/db'" when models.length > 0 (i.e., when aliases will be produced).
Locate renderGeneratedModelTypes and wrap or conditionally add that import in
the returned array/build so the import is omitted for empty models, matching the
conditional pattern used in
renderGeneratedQueueTypes/renderGeneratedBroadcastTypes/renderGeneratedEventTypes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 62eef95a-1145-406a-a2e9-83455e31154b

📥 Commits

Reviewing files that changed from the base of the PR and between 37238af and 7b02ca6.

📒 Files selected for processing (59)
  • apps/blog-next/app/login/page.tsx
  • apps/blog-next/proxy.ts
  • apps/blog-nuxt/app/app.vue
  • apps/blog-nuxt/app/middleware/guest-only.global.ts
  • apps/blog-nuxt/app/pages/admin/categories/[id]/edit.vue
  • apps/blog-nuxt/app/pages/admin/categories/index.vue
  • apps/blog-nuxt/app/pages/admin/index.vue
  • apps/blog-nuxt/app/pages/admin/posts/[id]/edit.vue
  • apps/blog-nuxt/app/pages/admin/posts/index.vue
  • apps/blog-nuxt/app/pages/admin/posts/new.vue
  • apps/blog-nuxt/app/pages/admin/tags/[id]/edit.vue
  • apps/blog-nuxt/app/pages/admin/tags/index.vue
  • apps/blog-nuxt/app/pages/categories/[slug].vue
  • apps/blog-nuxt/app/pages/forgot-password.vue
  • apps/blog-nuxt/app/pages/index.vue
  • apps/blog-nuxt/app/pages/login.vue
  • apps/blog-nuxt/app/pages/posts/[slug].vue
  • apps/blog-nuxt/app/pages/posts/index.vue
  • apps/blog-nuxt/app/pages/register.vue
  • apps/blog-nuxt/app/pages/reset-password.vue
  • apps/blog-nuxt/app/pages/tags/[slug].vue
  • apps/blog-nuxt/app/pages/verify-email.vue
  • apps/blog-nuxt/package.json
  • apps/blog-nuxt/server/api/forgot-password.post.ts
  • apps/blog-nuxt/server/api/login.post.ts
  • apps/blog-nuxt/server/api/register.post.ts
  • apps/blog-nuxt/server/api/reset-password.post.ts
  • apps/blog-nuxt/server/api/verify-email.post.ts
  • apps/blog-nuxt/server/holo-models.d.ts
  • apps/blog-nuxt/shared/schemas/auth.ts
  • apps/blog-sveltekit/src/hooks.server.ts
  • apps/docs/docs/auth/current-auth-client.md
  • apps/docs/docs/forms/framework-integration.md
  • apps/docs/docs/forms/server-validation.md
  • packages/adapter-next/src/request-context.ts
  • packages/adapter-next/src/runtime.ts
  • packages/adapter-next/src/server.ts
  • packages/adapter-next/tests/server.test.ts
  • packages/adapter-nuxt/package.json
  • packages/adapter-nuxt/src/module.ts
  • packages/adapter-nuxt/src/runtime/server/protection.d.ts
  • packages/adapter-nuxt/src/runtime/server/protection.ts
  • packages/adapter-nuxt/src/runtime/shims.d.ts
  • packages/adapter-nuxt/tests/module.test.ts
  • packages/adapter-nuxt/tests/package.test.ts
  • packages/adapter-nuxt/tests/protection.test.ts
  • packages/adapter-nuxt/tests/setup.test.ts
  • packages/adapter-sveltekit/src/server.ts
  • packages/adapter-sveltekit/tests/server.test.ts
  • packages/auth/src/client-runtime.ts
  • packages/auth/tests/package.test.ts
  • packages/cli/src/dev.ts
  • packages/cli/src/project/discovery.ts
  • packages/cli/src/project/registry.ts
  • packages/cli/src/project/scaffold/framework-renderers.ts
  • packages/cli/src/project/scaffold/framework.ts
  • packages/cli/src/project/shared.ts
  • packages/cli/tests/cli.test.ts
  • tests/example-app-auth-flow.mjs
💤 Files with no reviewable changes (1)
  • apps/blog-nuxt/server/holo-models.d.ts

Comment thread apps/docs/docs/auth/current-auth-client.md
Comment thread packages/adapter-next/src/server.ts
Comment thread packages/adapter-nuxt/src/runtime/server/protection.ts
Comment thread packages/adapter-sveltekit/src/server.ts
Comment thread packages/adapter-sveltekit/src/server.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
apps/docs/docs/auth/current-auth-client.md (1)

107-110: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Missing error handling for refreshUser() prevents navigation on failure.

If auth.refreshUser() rejects, the subsequent invalidateAll() and goto calls are never reached, leaving the user on the login page despite successful authentication. Apply the same error-handling pattern used in the Next.js example for consistency.

📝 Proposed fix
       if (submission?.ok === true && typeof submission.data?.redirectTo === 'string') {
-        await auth.refreshUser()
+        try {
+          await auth.refreshUser()
+        } catch (error) {
+          console.warn('Auth refresh failed after login.', error)
+        }
+
         await invalidateAll()
         await goto(submission.data.redirectTo)
       }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/docs/docs/auth/current-auth-client.md` around lines 107 - 110, The call
to auth.refreshUser() can reject and block subsequent navigation; wrap the
refresh in a try/catch (as done in the Next.js example) so errors from
auth.refreshUser() are caught and handled (log or ignore), then always call
invalidateAll() and goto(submission.data.redirectTo) after the catch; update the
block around refreshUser/invalidateAll/goto to ensure refreshUser failures do
not prevent invalidateAll() or goto() from running.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/docs/docs/auth/current-auth-client.md`:
- Around line 84-86: The code in the condition where `submission?.ok === true`
and `submission.data?.redirectTo` is a string calls `refreshUser()` without
handling possible rejections, preventing `navigateTo` on failure. To fix this,
wrap the `refreshUser()` call in a try-catch block or use `.catch()` to handle
errors, ensuring that `navigateTo(submission.data.redirectTo)` is still invoked
even if `refreshUser()` fails, following the error-handling pattern demonstrated
in the Next.js example.

---

Duplicate comments:
In `@apps/docs/docs/auth/current-auth-client.md`:
- Around line 107-110: The call to auth.refreshUser() can reject and block
subsequent navigation; wrap the refresh in a try/catch (as done in the Next.js
example) so errors from auth.refreshUser() are caught and handled (log or
ignore), then always call invalidateAll() and goto(submission.data.redirectTo)
after the catch; update the block around refreshUser/invalidateAll/goto to
ensure refreshUser failures do not prevent invalidateAll() or goto() from
running.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cd6a1fce-7291-4787-9611-0b9d3c64da41

📥 Commits

Reviewing files that changed from the base of the PR and between 7b02ca6 and 9eef907.

📒 Files selected for processing (11)
  • apps/docs/docs/auth/current-auth-client.md
  • packages/adapter-next/src/server.ts
  • packages/adapter-next/tests/server.test.ts
  • packages/adapter-nuxt/src/module.ts
  • packages/adapter-nuxt/src/runtime/server/protection.ts
  • packages/adapter-nuxt/tests/module.test.ts
  • packages/adapter-nuxt/tests/protection.test.ts
  • packages/adapter-sveltekit/src/server.ts
  • packages/adapter-sveltekit/tests/server.test.ts
  • packages/cli/src/project/registry.ts
  • packages/cli/tests/cli.test.ts
🚧 Files skipped from review as they are similar to previous changes (8)
  • packages/adapter-nuxt/tests/module.test.ts
  • packages/adapter-nuxt/tests/protection.test.ts
  • packages/adapter-nuxt/src/module.ts
  • packages/adapter-sveltekit/tests/server.test.ts
  • packages/adapter-sveltekit/src/server.ts
  • packages/adapter-nuxt/src/runtime/server/protection.ts
  • packages/adapter-next/src/server.ts
  • packages/cli/tests/cli.test.ts

Comment thread apps/docs/docs/auth/current-auth-client.md
@cobraprojects
cobraprojects merged commit a2cd999 into main May 7, 2026
1 check passed
@cobraprojects
cobraprojects deleted the feat-guest-middleware branch May 7, 2026 10:30
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