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
2 changes: 1 addition & 1 deletion app/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function LoginPage() {
<p className="text-center text-slate-600 mb-8">Track your billable hours</p>

<button
onClick={() => signIn('github', { redirectTo: '/dashboard' })}
onClick={() => signIn('github', { callbackUrl: '/dashboard' })}
className="w-full py-3 px-4 bg-slate-900 text-white font-semibold rounded-lg hover:bg-slate-800 transition-colors flex items-center justify-center gap-2"
>
<svg className="w-5 h-5" fill="currentColor" viewBox="0 0 24 24">
Expand Down
1 change: 1 addition & 0 deletions auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import GithubProvider from 'next-auth/providers/github';

export const authOptions: NextAuthOptions = {
secret: process.env.NEXTAUTH_SECRET,
debug: process.env.NODE_ENV !== 'production',
providers: [
GithubProvider({
clientId: process.env.AUTH_GITHUB_ID!,
Expand Down
20 changes: 17 additions & 3 deletions middleware.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
import auth from 'next-auth/middleware';
import auth, { type NextRequestWithAuth } from 'next-auth/middleware';
import { NextResponse } from 'next/server';

export const middleware = auth;
export async function middleware(req: NextRequestWithAuth) {
const url = req.nextUrl.clone();
if (url.pathname === '/api/auth/callback/github' && url.searchParams.has('iss')) {
url.searchParams.delete('iss');
return NextResponse.redirect(url);
}
return auth(req);
}

export const config = {
matcher: ['/dashboard/:path*', '/invoices/:path*', '/clients/:path*', '/timer/:path*'],
matcher: [
'/dashboard/:path*',
'/invoices/:path*',
'/clients/:path*',
'/timer/:path*',
'/api/auth/callback/github',
],
};
Loading