mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-11 13:14:06 +01:00
⚡ cache assets
This commit is contained in:
parent
3de6cf003e
commit
358bf87329
@ -52,6 +52,7 @@ router.get("/:channel_id/:id/:filename", async (req: Request, res: Response) =>
|
|||||||
const type = await FileType.fromBuffer(file);
|
const type = await FileType.fromBuffer(file);
|
||||||
|
|
||||||
res.set("Content-Type", type?.mime);
|
res.set("Content-Type", type?.mime);
|
||||||
|
res.set("Cache-Control", "public, max-age=31536000");
|
||||||
|
|
||||||
return res.send(file);
|
return res.send(file);
|
||||||
});
|
});
|
||||||
|
@ -52,6 +52,7 @@ router.get("/:user_id/:id", async (req: Request, res: Response) => {
|
|||||||
const type = await FileType.fromBuffer(file);
|
const type = await FileType.fromBuffer(file);
|
||||||
|
|
||||||
res.set("Content-Type", type?.mime);
|
res.set("Content-Type", type?.mime);
|
||||||
|
res.set("Cache-Control", "public, max-age=31536000");
|
||||||
|
|
||||||
return res.send(file);
|
return res.send(file);
|
||||||
});
|
});
|
||||||
|
@ -7,7 +7,10 @@ if (process.env.STORAGE_LOCATION) {
|
|||||||
if (!process.env.STORAGE_LOCATION.startsWith("/")) {
|
if (!process.env.STORAGE_LOCATION.startsWith("/")) {
|
||||||
process.env.STORAGE_LOCATION = __dirname + "/../" + process.env.STORAGE_LOCATION;
|
process.env.STORAGE_LOCATION = __dirname + "/../" + process.env.STORAGE_LOCATION;
|
||||||
}
|
}
|
||||||
} else process.env.STORAGE_LOCATION = __dirname + "/../files/";
|
} else {
|
||||||
|
process.env.STORAGE_LOCATION = __dirname + "/../files/";
|
||||||
|
process.env.STORAGE_PROVIDER = "file";
|
||||||
|
}
|
||||||
|
|
||||||
const server = new CDNServer({ port: Number(process.env.PORT) || 3003 });
|
const server = new CDNServer({ port: Number(process.env.PORT) || 3003 });
|
||||||
server
|
server
|
||||||
|
Loading…
Reference in New Issue
Block a user