mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 22:09:16 +01:00
feat(api): 🔒 Make all media be proxied through an internal proxy
This commit is contained in:
parent
9547cd097a
commit
ead34b818f
8 changed files with 54 additions and 18 deletions
|
|
@ -3,7 +3,7 @@ import { errorResponse, response } from "@response";
|
|||
|
||||
export const meta = applyConfig({
|
||||
allowedMethods: ["GET"],
|
||||
route: "/api/v1/media/:id",
|
||||
route: "/api/media/:id",
|
||||
ratelimits: {
|
||||
max: 100,
|
||||
duration: 60,
|
||||
|
|
|
|||
27
server/api/media/proxy/index.ts
Normal file
27
server/api/media/proxy/index.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { apiRoute, applyConfig } from "@api";
|
||||
import { errorResponse, response } from "@response";
|
||||
import { z } from "zod";
|
||||
|
||||
export const meta = applyConfig({
|
||||
allowedMethods: ["GET"],
|
||||
route: "/api/media/proxy",
|
||||
ratelimits: {
|
||||
max: 100,
|
||||
duration: 60,
|
||||
},
|
||||
auth: {
|
||||
required: false,
|
||||
},
|
||||
});
|
||||
|
||||
export const schema = z.object({
|
||||
url: z.string(),
|
||||
});
|
||||
|
||||
export default apiRoute<typeof meta, typeof schema>(
|
||||
async (req, matchedRoute, extraData) => {
|
||||
const { url } = extraData.parsedRequest;
|
||||
|
||||
return fetch(url);
|
||||
},
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue