feat: integrate Cloudinary image upload, Instagram Feed, and fix Next.js warnings

This commit is contained in:
2026-06-09 21:28:45 +03:00
parent 2b3392dcb1
commit a4ad9344a0
52 changed files with 4300 additions and 263 deletions
+44
View File
@@ -0,0 +1,44 @@
import { SignJWT, jwtVerify } from 'jose';
import { cookies } from 'next/headers';
const secretKey = process.env.JWT_SECRET || 'fallback-secret-for-development-only-do-not-use-in-prod';
const key = new TextEncoder().encode(secretKey);
export async function signToken(payload: any) {
return await new SignJWT(payload)
.setProtectedHeader({ alg: 'HS256' })
.setIssuedAt()
.setExpirationTime('1d') // 1 günlük oturum süresi
.sign(key);
}
export async function verifyToken(token: string) {
try {
const { payload } = await jwtVerify(token, key);
return payload;
} catch (error) {
return null;
}
}
export async function setAuthCookie(token: string) {
const cookieStore = await cookies();
cookieStore.set('admin_token', token, {
httpOnly: true,
secure: process.env.NODE_ENV === 'production',
sameSite: 'lax',
maxAge: 60 * 60 * 24, // 1 day in seconds
path: '/',
});
}
export async function removeAuthCookie() {
const cookieStore = await cookies();
cookieStore.delete('admin_token');
}
export async function getAuthCookie() {
const cookieStore = await cookies();
const token = cookieStore.get('admin_token')?.value;
return token ? await verifyToken(token) : null;
}