fix(server/api): PUBLIC_DOMAIN inclut le sous-domaine de l'instance

- Avant : PS_DOMAIN valait 'alfrednobel.edudeploy.com' → redirection vers le dashboard
- Après : PS_DOMAIN vaut '<id>.alfrednobel.edudeploy.com' → bonne URL publique
This commit is contained in:
EduBox Dev
2026-06-17 20:52:30 +00:00
parent 5c4c9f3531
commit 2d57857221
+7 -5
View File
@@ -68,7 +68,8 @@ export async function POST(req: NextRequest) {
});
const domain = node?.student?.class.establishment?.domain;
const publicUrl = domain ? `https://${instance.id}.${domain}` : null;
const publicDomain = domain ? `${instance.id}.${domain}` : "localhost";
const publicUrl = domain ? `https://${publicDomain}` : null;
const sent = sendToNode(nodeId, {
action: "start",
@@ -79,7 +80,7 @@ export async function POST(req: NextRequest) {
.replace(/{PORT}/g, String(instance.port))
.replace(/{INSTANCE_ID}/g, instance.id)
.replace(/{PUBLIC_URL}/g, publicUrl || `http://localhost:${instance.port}`)
.replace(/{PUBLIC_DOMAIN}/g, domain || "localhost"),
.replace(/{PUBLIC_DOMAIN}/g, publicDomain),
});
if (!sent) {
@@ -96,7 +97,8 @@ export async function PATCH(req: NextRequest) {
if (!instance) return NextResponse.json({ error: "Not found" }, { status: 404 });
const domain = instance.node.student?.class.establishment?.domain;
const publicUrl = domain ? `https://${instance.id}.${domain}` : null;
const publicDomain = domain ? `${instance.id}.${domain}` : "localhost";
const publicUrl = domain ? `https://${publicDomain}` : null;
if (action === "stop") {
sendToNode(instance.nodeId, { action: "delete", instanceId: instance.id });
@@ -111,7 +113,7 @@ export async function PATCH(req: NextRequest) {
.replace(/{PORT}/g, String(instance.port))
.replace(/{INSTANCE_ID}/g, instance.id)
.replace(/{PUBLIC_URL}/g, publicUrl || `http://localhost:${instance.port}`)
.replace(/{PUBLIC_DOMAIN}/g, domain || "localhost"),
.replace(/{PUBLIC_DOMAIN}/g, publicDomain),
});
if (!sent) await prisma.instance.update({ where: { id }, data: { status: "error" } });
} else if (action === "reset") {
@@ -124,7 +126,7 @@ export async function PATCH(req: NextRequest) {
.replace(/{PORT}/g, String(instance.port))
.replace(/{INSTANCE_ID}/g, instance.id)
.replace(/{PUBLIC_URL}/g, publicUrl || `http://localhost:${instance.port}`)
.replace(/{PUBLIC_DOMAIN}/g, domain || "localhost"),
.replace(/{PUBLIC_DOMAIN}/g, publicDomain),
});
if (!sent) await prisma.instance.update({ where: { id }, data: { status: "error" } });
}