Files
zeekay 2979d0bffb Fix Edge Runtime crash: remove ioredis from middleware bundle
- 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
2026-03-01 08:33:05 -08:00

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 });
}