Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions apps/app/next.config.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
import "./src/env.mjs";

const config = {
poweredByHeader: false,
reactStrictMode: true,
images: {
remotePatterns: [
{
protocol: "https",
hostname: "**",
},
],
},
transpilePackages: ["@bubba/ui"],
logging: {
fetches: {
fullUrl: process.env.LOG_FETCHES === "true",
},
},
async rewrites() {
return [
{
source: "/ingest/static/:path*",
destination: "https://us-assets.i.posthog.com/static/:path*",
},
{
source: "/ingest/:path*",
destination: "https://us.i.posthog.com/:path*",
},
{
source: "/ingest/decide",
destination: "https://us.i.posthog.com/decide",
},
];
},
skipTrailingSlashRedirect: true,
poweredByHeader: false,
reactStrictMode: true,
images: {
remotePatterns: [
{
protocol: "https",
hostname: "**",
},
],
},
transpilePackages: ["@bubba/ui"],
logging: {
fetches: {
fullUrl: process.env.LOG_FETCHES === "true",
},
},
async rewrites() {
return [
{
source: "/ingest/static/:path*",
destination: "https://us-assets.i.posthog.com/static/:path*",
},
{
source: "/ingest/:path*",
destination: "https://us.i.posthog.com/:path*",
},
{
source: "/ingest/decide",
destination: "https://us.i.posthog.com/decide",
},
];
},
skipTrailingSlashRedirect: true,
};

export default config;
54 changes: 26 additions & 28 deletions apps/app/src/app/[locale]/(app)/(dashboard)/[orgId]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,46 +1,44 @@
import { auth } from "@/auth";
import { Header } from "@/components/header";
import { Sidebar } from "@/components/sidebar";
import { db } from "@bubba/db";
import dynamic from "next/dynamic";
import { redirect } from "next/navigation";
import { cache } from "react";

const HotKeys = dynamic(
() => import("@/components/hot-keys").then((mod) => mod.HotKeys),
{
ssr: true,
},
() => import("@/components/hot-keys").then((mod) => mod.HotKeys),
{
ssr: true,
},
);

export default async function Layout({
children,
params,
children,
params,
}: {
children: React.ReactNode;
params: Promise<{ orgId: string }>;
children: React.ReactNode;
params: Promise<{ orgId: string }>;
}) {
const session = await auth();
const orgId = (await params).orgId;
const session = await auth();
const orgId = (await params).orgId;

if (!session) {
redirect("/auth");
}
if (!session) {
redirect("/auth");
}

if (!orgId) {
redirect("/");
}
if (!orgId) {
redirect("/");
}

return (
<div className="relative">
<Sidebar />
return (
<div className="relative">
<Sidebar />

<div className="mx-4 md:ml-[95px] md:mr-10 pb-8">
<Header />
<main>{children}</main>
</div>
<div className="mx-4 md:ml-[95px] md:mr-10 pb-8">
<Header />
<main>{children}</main>
</div>

<HotKeys />
</div>
);
<HotKeys />
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ export default async function ApiKeysPage({
setStaticParamsLocale(locale);
const t = await getI18n();

const session = await auth();

if (!session?.user.organizationId) {
return redirect("/");
}

const apiKeys = await getApiKeys(session.user.organizationId);
const apiKeys = await getApiKeys();

return (
<div className="mx-auto max-w-7xl">
Expand All @@ -45,10 +39,16 @@ export async function generateMetadata({
};
}

const getApiKeys = cache(async (organizationId: string) => {
const getApiKeys = cache(async () => {
const session = await auth();

if (!session?.user.organizationId) {
return [];
}

const apiKeys = await db.organizationApiKey.findMany({
where: {
organizationId,
organizationId: session.user.organizationId,
isActive: true,
},
select: {
Expand Down
8 changes: 8 additions & 0 deletions apps/app/src/app/[locale]/(public)/auth/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
} from "@bubba/ui/accordion";
import type { Metadata } from "next";
import Link from "next/link";
import { auth } from "@/auth";
import { redirect } from "next/navigation";

export const metadata: Metadata = {
title: "Login | Comp AI",
Expand All @@ -21,6 +23,12 @@ export default async function Page({
searchParams: Promise<{ inviteCode?: string }>;
}) {
const t = await getI18n();
const session = await auth();

if (session?.user) {
redirect("/");
}

const { inviteCode } = await searchParams;

const defaultSignInOptions = (
Expand Down
Loading