124543d658
- Agent studioE5 standalone en Go (console + systray) - VPN on-demand via tailscaled + tailscale up (authkey Headscale) - Resolver/serveur dans le tailnet studioe5 - Caddy on-demand TLS pour les instances - Nouveaux endpoints serveur /api/internal/send-to-node - Suppression des anciens binaires edubox-agent - Suivi dans SUIVI_VPN_ONDEMAND.md
32 lines
841 B
TypeScript
32 lines
841 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { prisma } from "@/lib/prisma";
|
|
|
|
const MAIN_DOMAIN = process.env.MAIN_DOMAIN || "alfrednobel.edudeploy.com";
|
|
|
|
export async function GET(req: NextRequest) {
|
|
const { searchParams } = new URL(req.url);
|
|
const domain = searchParams.get("domain");
|
|
|
|
if (!domain) {
|
|
return NextResponse.json({ ok: false }, { status: 400 });
|
|
}
|
|
|
|
if (
|
|
domain === MAIN_DOMAIN ||
|
|
domain === `headscale.${MAIN_DOMAIN}`
|
|
) {
|
|
return NextResponse.json({ ok: true });
|
|
}
|
|
|
|
if (!domain.endsWith(`.${MAIN_DOMAIN}`)) {
|
|
return NextResponse.json({ ok: false }, { status: 400 });
|
|
}
|
|
|
|
const subdomain = domain.replace(`.${MAIN_DOMAIN}`, "");
|
|
const instance = await prisma.instance.findUnique({
|
|
where: { id: subdomain },
|
|
});
|
|
|
|
return NextResponse.json({ ok: !!instance });
|
|
}
|