first commit

This commit is contained in:
Beyhan Oğur
2026-04-26 22:14:08 +03:00
commit b2825e1698
41 changed files with 14258 additions and 0 deletions

53
lib/auth-options.ts Normal file
View File

@@ -0,0 +1,53 @@
import type { NextAuthOptions } from "next-auth";
import GoogleProvider from "next-auth/providers/google";
import GitHubProvider from "next-auth/providers/github";
/**
* NextAuth options: Google & GitHub OAuth.
* Env: NEXTAUTH_SECRET veya NEXT_AUTH_SECRET, NEXTAUTH_URL,
* GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET,
* GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET
*/
const isProd = process.env.NODE_ENV === "production";
export const authOptions: NextAuthOptions = {
secret: process.env.NEXTAUTH_SECRET ?? process.env.NEXT_AUTH_SECRET,
useSecureCookies: isProd,
cookies: {
sessionToken: {
name: `${isProd ? "__Secure-" : ""}next-auth.session-token`,
options: {
httpOnly: true,
sameSite: "lax",
path: "/",
secure: isProd,
maxAge: 30 * 24 * 60 * 60, // 30 gün
},
},
},
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID ?? "",
clientSecret: process.env.GOOGLE_CLIENT_SECRET ?? "",
}),
GitHubProvider({
clientId: process.env.GITHUB_CLIENT_ID ?? "",
clientSecret: process.env.GITHUB_CLIENT_SECRET ?? "",
authorization: {
params: {
scope: "user:email",
},
},
}),
],
pages: {
signIn: "/auth/login",
},
callbacks: {
redirect({ url, baseUrl }) {
if (url.startsWith("/")) return `${baseUrl}${url}`;
if (new URL(url).origin === baseUrl) return url;
return baseUrl;
},
},
};