mirror of
https://github.com/hanzoai/dataroom.git
synced 2026-10-30 18:41:07 +00:00
- Dynamic import DomainMiddleware to avoid pulling ioredis into Edge bundle - Add hanzo.ai to APP_DOMAINS exclusion list in isCustomDomain - DomainMiddleware now uses fetch to internal API for Redis lookups - Create /api/internal/domain-redirect endpoint for Edge-safe KV access
22 lines
623 B
TypeScript
22 lines
623 B
TypeScript
import type { NextApiRequest, NextApiResponse } from "next";
|
|
|
|
import { getDomainRedirectUrl } from "@/lib/api/domains/redis";
|
|
|
|
export default async function handler(
|
|
req: NextApiRequest,
|
|
res: NextApiResponse,
|
|
) {
|
|
// Only allow internal middleware calls
|
|
if (req.headers["x-middleware-internal"] !== "1") {
|
|
return res.status(403).json({ error: "Forbidden" });
|
|
}
|
|
|
|
const host = req.query.host as string;
|
|
if (!host) {
|
|
return res.status(400).json({ error: "Missing host" });
|
|
}
|
|
|
|
const redirectUrl = await getDomainRedirectUrl(host);
|
|
return res.status(200).json({ redirectUrl: redirectUrl || null });
|
|
}
|