Skip to content

Commit

Permalink
fix(dashboard): undefined loader error in spa from bad cookie cache (#43
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ayuhito authored Jun 24, 2024
1 parent 1559610 commit 991f5e8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion dashboard/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import {
NotFoundError,
} from '@/components/layout/Error';
import theme from '@/styles/theme';
import { hasSession } from '@/utils/cookies';
import { EXPIRE_LOGGED_IN, hasSession } from '@/utils/cookies';

interface LoaderData {
isLoggedIn: boolean;
Expand Down Expand Up @@ -199,6 +199,15 @@ export const ErrorBoundary = () => {
}

if (error instanceof Error) {
// If the error is due to a loader mismatch, reload the page as it may be
// related to a bad cookie cache from the API restarting. This is probably
// a bug in Remix SPA mode.
if (error.message.startsWith('You defined a loader for route "routes')) {
document.cookie = EXPIRE_LOGGED_IN;
window.location.reload();
return HydrateFallback();
}

return (
<Document>
<InternalServerError error={error.message} />
Expand Down

0 comments on commit 991f5e8

Please sign in to comment.