server/middlewares/url-check.ts
Jesse Wierzbinski e3e285571e
Some checks failed
Mirror to Codeberg / Mirror (push) Failing after 0s
refactor(api): 🏷️ Port all /api/v1/accounts to use new schemas
2025-02-13 01:31:15 +01:00

19 lines
536 B
TypeScript

import { createMiddleware } from "hono/factory";
import { config } from "~/packages/config-manager";
export const urlCheck = createMiddleware(async (context, next) => {
// Check that request URL matches base_url
const baseUrl = config.http.base_url;
if (new URL(context.req.url).origin !== baseUrl.origin) {
return context.json(
{
error: `Request URL ${context.req.url} does not match base URL ${baseUrl.origin}`,
},
400,
);
}
await next();
});