fix: initialize hosted Studio behind HTTPS reverse proxies

This commit is contained in:
Clintchiz committed 2026-10-19 13:59:38 +05:30
1 parent 60467a4c05
commit 953e928b05
9 files changed
+186 -4

No files matched your search

+5 -2
View File
@@ -2,6 +2,7 @@ import type { Middleware } from "@wrnexus/core";
import type { createStudioHandler } from "@wrnexus/design-studio/server";
import { studioAI } from "../lib/studio-ai.ts";
import { addStudioGuide, studioHelpScript } from "../lib/studio-guide.ts";
import { studioRequest } from "../lib/studio-origin.ts";
let studio: ReturnType<typeof createStudioHandler> | undefined;
let ai: ReturnType<typeof studioAI> | undefined;
@@ -14,8 +15,10 @@ const designStudio: Middleware = async (ctx, next) => {
headers: { location: "/design-studio/" },
});
if (!url.pathname.startsWith("/design-studio/")) return next();
const request = studioRequest(ctx.req);
if (request instanceof Response) return request;
ai ??= studioAI(process.env.APIMART_API_KEY?.trim());
const generated = await ai(ctx.req);
const generated = await ai(request);
if (generated) return generated;
if (
url.pathname === "/design-studio/site-help.js" &&
@@ -39,7 +42,7 @@ const designStudio: Middleware = async (ctx, next) => {
studio = undefined;
throw error;
});
const response = await (await studio)(ctx.req);
const response = await (await studio)(request);
if (
url.pathname === "/design-studio/" &&
response.ok &&