mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 16:38:19 +01:00
20 lines
544 B
TypeScript
20 lines
544 B
TypeScript
import { config } from "@versia-server/config";
|
|
import { createMiddleware } from "hono/factory";
|
|
|
|
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();
|
|
return;
|
|
});
|