Initial commit: page-manager Next.js app with Coolify deploy support
Replace Vercel-specific infra (Cron, Blob) with self-hosted equivalents for deployment to Coolify: in-container cron scheduler (scripts/cron-runner.mjs) and disk-based upload storage served via /api/uploads/[...path]. Add Dockerfile, .dockerignore, and /api/health for container health checks. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { getCurrentUser, isSuperadmin } from "@/lib/auth/user";
|
||||
import { authorizeUrl, createOAuthState, OAUTH_STATE_COOKIE } from "@/lib/facebook/oauth";
|
||||
import { safeFacebookErrorMessage } from "@/lib/facebook/client";
|
||||
|
||||
/** SUPERADMIN only: redirects to the Facebook consent dialog. */
|
||||
export async function GET(req: Request) {
|
||||
const origin = new URL(req.url).origin;
|
||||
const user = await getCurrentUser();
|
||||
if (!user || !isSuperadmin(user)) return NextResponse.redirect(new URL("/pages?fb_error=forbidden", origin));
|
||||
|
||||
try {
|
||||
const { nonce, cookie } = await createOAuthState(user.id);
|
||||
const res = NextResponse.redirect(authorizeUrl(origin, nonce));
|
||||
res.cookies.set(OAUTH_STATE_COOKIE, cookie, {
|
||||
httpOnly: true,
|
||||
secure: process.env.NODE_ENV === "production",
|
||||
// Lax: must survive the top-level redirect back from facebook.com.
|
||||
sameSite: "lax",
|
||||
path: "/api/facebook/oauth",
|
||||
maxAge: 600,
|
||||
});
|
||||
return res;
|
||||
} catch (e) {
|
||||
const msg = safeFacebookErrorMessage(e, "fb:oauth:start");
|
||||
return NextResponse.redirect(new URL(`/pages?fb_error=${encodeURIComponent(msg)}`, origin));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user