mirror of
https://github.com/versia-pub/server.git
synced 2026-04-28 13:19:16 +02:00
refactor: 🚚 Organize code into sub-packages, instead of a single large package
This commit is contained in:
parent
79742f47dc
commit
a6d3ebbeef
366 changed files with 942 additions and 833 deletions
19
packages/api/middlewares/url-check.ts
Normal file
19
packages/api/middlewares/url-check.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
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;
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue