handling-authentication-errors

Implements auth error handling for FuseBase app tokens and backend session probes.

5|2|Updated Feb 9, 2026
One-click install
npx skills add https://github.com/ryan-haver/fusebase-mcp --skill handling-authentication-errors-ryan-haver
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: handling-authentication-errors
Source: https://github.com/ryan-haver/fusebase-mcp/tree/main/apps/client-portal-dashboard/.claude/skills/handling-authentication-errors
Command: npx skills add https://github.com/ryan-haver/fusebase-mcp --skill handling-authentication-errors-ryan-haver

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? FuseBase apps often misclassify transient failures (deploy restarts, proxy 502s, network blips) as logouts, falsely clearing sessions and showing login screens to authenticated users. This Skill defines the required patterns for distinguishing real auth expiry from temporary server unavailability. ## Core Features & Use Cases - Session probe invariant: Classifies /api/account/me responses into authenticated, anon, blocked, or unknown, with retry logic that tolerates deploy cold starts without clearing the httpOnly session cookie. - Platform token expiry handling: Detects AppTokenValidationError (401) from Gate/Dashboard proxy calls at any nesting level and surfaces a Session Expired modal with a page-refresh action. - Edge-case rules: Covers the /users/me anonymous-visitor exception, proxy 302/opaqueredirect workarounds (NIM-42325), status-0 wrong-host diagnosis, and mutation reconciliation after ambiguous failures. - Use Case: When building a FuseBase client portal SPA, apply these patterns so users refreshing during a fusebase deploy see a retryable "Can't reach server" message instead of being logged out. ## Quick Start Implement the session probe and AppTokenValidationError handling patterns in my FuseBase app so deploy restarts never log users out.

Frequently Asked Questions about handling-authentication-errors

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle expired app tokens in a FuseBase app?▼

Detect AppTokenValidationError in API catch blocks by checking err.name, err.data?.name, err.error?.name, and err.body?.name, then throw a custom AuthTokenExpiredError. At the UI level, show a Session Expired modal with a Refresh page button that calls window.location.reload().

How should a SPA check login session on load without false logouts?▼

Probe GET /api/account/me with credentials included and classify responses: 401 means anon, 403 with known business codes means blocked, and anything else means unknown. Retry unknown verdicts with delays of 0, 400, and 1200 ms before showing a transient server error, never clearing the session cookie.

Why do users get logged out during a fusebase deploy?▼

A deploy restarts the app backend, so requests during rollout can hit 502s or timeouts from the proxy while the pod is not ready. Code that treats any non-401 failure as logout falsely ends valid sessions; retry the session probe and show a retryable server-unavailable message instead.

Should a 401 from /users/me trigger a session expired modal?▼

No. For public apps, anonymous visitors receive a 401 from /users/me, which means not authenticated rather than session expired. Return null from the fetch and reserve AuthTokenExpiredError for Dashboard or data API 401s carrying AppTokenValidationError.

Why does fetch to /api fail with a network error instead of a 401?▼

The platform proxy may answer expired sessions with a 302 redirect, which fetch follows into a cross-origin CORS failure with no status or body. Use redirect: 'manual', detect opaqueredirect responses, then probe the session before deciding whether to show an auth modal.

What does HTTP status 0 on a getMe call indicate?▼

Status 0 is almost never an auth problem; it means the request went to the wrong platform host and died on network or CORS. Fix host resolution using same-origin relative paths, window.location.hostname, or /fusebase-env.json rather than build-time environment constants.