feat(auth): implement Bearer token fallback in fetchSessionUser for private network HTTP connections

- Expanded fetchSessionUser to include Bearer token from localStorage as a fallback for authentication when Secure cookies fail.
- Updated headers to conditionally include Authorization if a token is present.
- Ensured compatibility with the recent fix for the Secure cookie flag on private network connections.
This commit is contained in:
GitHub Actions
2026-03-15 02:25:07 +00:00
parent 9d6ecd8f73
commit 6777f6e8ff
7 changed files with 1258 additions and 462 deletions
+7 -3
View File
@@ -9,12 +9,16 @@ export const AuthProvider: FC<{ children: ReactNode }> = ({ children }) => {
const authRequestVersionRef = useRef(0);
const fetchSessionUser = useCallback(async (): Promise<User> => {
const headers: Record<string, string> = { Accept: 'application/json' };
const stored = localStorage.getItem('charon_auth_token');
if (stored) {
headers['Authorization'] = `Bearer ${stored}`;
}
const response = await fetch('/api/v1/auth/me', {
method: 'GET',
credentials: 'include',
headers: {
Accept: 'application/json',
},
headers,
});
if (!response.ok) {