mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-09-30 11:12:35 +02:00
On mount, AuthContext.checkAuthStatus restores the persisted "Remember Me" token from localStorage and validates it via GET /auth/me. The catch around that call cleared the token on ANY failure, not just a definitive 401 invalid-token — so a brief backend-not-ready or reverse-proxy hiccup during page load (plausible right after a container restart, e.g. on Unraid) would delete a still-valid token. Because the token was deleted, a reload couldn't recover it and the user was bounced to the login screen. Token validation now retries transient failures (up to 3 attempts with short backoff) and only discards the token on a definitive 401 — which request() already handles (clears the token and dispatches auth:expired). Transient / 5xx / network errors leave the persisted token intact so the session survives a slow load. "Remember Me" stays client-storage only; it does not extend the server-side JWT lifetime (session_max_hours, default 24h). Adds AuthContext tests: transient /auth/me failure keeps the token, a definitive 401 clears it, and a valid token loads the user. Rebuilt frontend bundle.
React + TypeScript + Vite
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
- @vitejs/plugin-react uses Babel (or oxc when used in rolldown-vite) for Fast Refresh
- @vitejs/plugin-react-swc uses SWC for Fast Refresh
React Compiler
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see this documentation.
Expanding the ESLint configuration
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Remove tseslint.configs.recommended and replace with this
tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
tseslint.configs.stylisticTypeChecked,
// Other configs...
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
You can also install eslint-plugin-react-x and eslint-plugin-react-dom for React-specific lint rules:
// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Enable lint rules for React
reactX.configs['recommended-typescript'],
// Enable lint rules for React DOM
reactDom.configs.recommended,
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])