fix /setup redirect issue

This commit is contained in:
Milo Schwartz 2024-10-26 23:57:29 -04:00
parent 8a8c42e3b1
commit 4a5bd7e18a
No known key found for this signature in database
3 changed files with 6 additions and 21 deletions

View file

@ -9,7 +9,6 @@ RUN npm install --legacy-peer-deps
COPY . .
RUN npx drizzle-kit generate --dialect sqlite --schema ./server/db/schema.ts --out migrations
RUN ls migrations
RUN npm run build

View file

@ -22,25 +22,6 @@ export default async function RootLayout({
}: Readonly<{
children: React.ReactNode;
}>) {
const user = await verifySession();
let orgs: ListOrgsResponse["orgs"] = [];
if (user) {
try {
const res = await internal.get<AxiosResponse<ListOrgsResponse>>(
`/orgs`,
await authCookieHeader()
);
if (res && res.data.data.orgs) {
orgs = res.data.data.orgs;
}
} catch {}
if (!orgs.length) {
redirect(`/setup`);
}
}
return (
<html suppressHydrationWarning>
<body className={`${font.className} pb-3`}>

View file

@ -16,7 +16,6 @@ export default async function Page(props: {
if (!user) {
redirect("/auth/login");
return;
}
let orgs: ListOrgsResponse["orgs"] = [];
@ -25,13 +24,19 @@ export default async function Page(props: {
`/orgs`,
await authCookieHeader()
);
if (res && res.data.data.orgs) {
orgs = res.data.data.orgs;
}
} catch (e) {
console.error(e);
}
if (!orgs.length) {
redirect("/setup");
}
return (
<>
<LandingProvider user={user}>