Skip to content

Commit

Permalink
fix(#71): correct full docker compose to use .env.docker
Browse files Browse the repository at this point in the history
  • Loading branch information
georgeherby committed Mar 10, 2024
1 parent cf12259 commit 77c6868
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/ui/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ LANGTRACE_API_URL=http://localhost:1984

# Auth
NEXTAUTH_ENABLE=false
NEXTAUTH_URL=http://localhost:3000
#NEXTAUTH_URL=http://localhost:3000
#NEXTAUTH_SECRET=

## Github
Expand Down
9 changes: 8 additions & 1 deletion packages/ui/src/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { authOptions } from '@/lib/utils/auth-options';
import NextAuth from 'next-auth';
import { NextApiRequest, NextApiResponse } from 'next';

const handler = NextAuth(authOptions);
const handler = (req: NextApiRequest, res: NextApiResponse) => {
if (process.env.NEXTAUTH_ENABLE === 'false') {
console.warn('NextAuth is disabled');
return res.status(200).json({ message: 'NextAuth is disabled' });
}
return NextAuth(req, res, authOptions);
};
export { handler as GET, handler as POST };
2 changes: 1 addition & 1 deletion packages/ui/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const metadata = {
export default async function Home() {
const session = await getServerSession(authOptions);

if (session) {
if (session || process.env.NEXTAUTH_ENABLE !== 'true') {
return <>
<div className="flex gap-4">
<div className="w-2/3">
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/src/components/global/app-bar/app-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export default async function AppBar() {
<Breadcrumbs/>
<div className="ml-auto flex items-end space-x-2">
<ThemeToggle/>
{session &&
{(session && process.env.NEXTAUTH_ENABLE === 'true')
&&
<SignOutIconButton/>
}
</div>
Expand Down
11 changes: 5 additions & 6 deletions packages/ui/src/components/global/app-bar/breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,17 @@ export default function Breadcrumbs() {
<Breadcrumb>
<BreadcrumbList>
{breadcrumbMap.map((item, index) => <>
{ index > 0 &&
<BreadcrumbSeparator/>}
<BreadcrumbItem key={index}>
{index > 0 &&
<BreadcrumbSeparator key={index+'-separator'}/>}
<BreadcrumbItem key={index+'-item'}>
{item.href ? (
<BreadcrumbLink href={item.href}>
<BreadcrumbLink key={index+'-link'} href={item.href}>
{item.label}
</BreadcrumbLink>
) : (
<BreadcrumbPage>{item.label}</BreadcrumbPage>
<BreadcrumbPage key={index+'-page'}>{item.label}</BreadcrumbPage>
)}
</BreadcrumbItem>

</>)}
</BreadcrumbList>
</Breadcrumb>
Expand Down
11 changes: 11 additions & 0 deletions packages/ui/src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
import { NextResponse } from 'next/server';
export { default } from 'next-auth/middleware';
import type { NextRequest } from 'next/server';

export function middleware(request: NextRequest) {
if (process.env.NEXTAUTH_ENABLE === 'false') {
console.warn('NextAuth is disabled middleware');
return NextResponse.next();
}
return NextResponse.redirect(new URL(request.url, request.url));
}

export const config = {
matcher: ['/:path*'],
};

0 comments on commit 77c6868

Please sign in to comment.