Switch from SuperTokens to NextAuth.js

BREAKING CHANGE: Replace SuperTokens with NextAuth.js

Why:
- SuperTokens had persistent Traefik routing issues
- SSL certificate not issuing correctly
- Complex infrastructure (separate container)
- NextAuth runs in Next.js app (simpler, no separate service)

Changes:
- Install next-auth, @auth/prisma-adapter, prisma
- Create NextAuth API route: app/api/auth/[...nextauth]/route.ts
- Add Prisma schema for NextAuth tables (users, sessions, accounts)
- Update auth page to use NextAuth signIn()
- Remove all SuperTokens code and dependencies
- Keep same Google OAuth (just simpler integration)

Benefits:
- No separate auth service needed
- No Traefik routing issues
- Sessions stored in Montreal PostgreSQL
- Simpler configuration
- Battle-tested, widely used

All authentication data stays in Montreal!

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-02-17 15:12:21 -08:00
parent 8cd95607a4
commit bbb22f1c37
12 changed files with 534 additions and 632 deletions

View File

@@ -1,32 +1,20 @@
"use client";
import { signIn } from "next-auth/react";
import { useState } from "react";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
export default function SuperTokensAuthComponent() {
export default function NextAuthComponent() {
const [isLoading, setIsLoading] = useState(false);
const handleGoogleSignIn = async () => {
setIsLoading(true);
try {
// Get the base URL from environment or current window
const baseUrl = process.env.NEXT_PUBLIC_APP_URL || window.location.origin;
const redirectUri = `${baseUrl}/api/auth/callback/google`;
// Get Google OAuth URL from SuperTokens
const response = await fetch(
`/api/auth/authorisationurl?thirdPartyId=google&redirectURIOnProviderDashboard=${encodeURIComponent(redirectUri)}`
);
const data = await response.json();
if (data.status === "OK") {
// Redirect to Google OAuth
window.location.href = data.urlWithQueryParams;
} else {
console.error("Failed to get auth URL:", data);
setIsLoading(false);
}
// Sign in with Google using NextAuth
await signIn("google", {
callbackUrl: "/marks-account/projects",
});
} catch (error) {
console.error("Google sign-in error:", error);
setIsLoading(false);

View File

@@ -1,18 +0,0 @@
"use client";
import React from "react";
import { useEffect } from "react";
import SuperTokensReact from "supertokens-auth-react";
import { frontendConfig } from "@/lib/supertokens/frontendConfig";
export const SuperTokensProvider: React.FC<React.PropsWithChildren<{}>> = ({
children,
}) => {
useEffect(() => {
if (typeof window !== "undefined") {
SuperTokensReact.init(frontendConfig());
}
}, []);
return <>{children}</>;
};