From b1b120ac9464c600dc4a5d795feccba179d79e5a Mon Sep 17 00:00:00 2001 From: Iacami Gevaerd Date: Thu, 2 Nov 2023 13:25:21 -0300 Subject: [PATCH] hiding base url --- app.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index 7fe2b22..ac05e8b 100644 --- a/app.js +++ b/app.js @@ -6,7 +6,7 @@ const sharp = require("sharp"); const app = express(); const PORT = 8080; const HOST = "0.0.0.0"; -const BASE_STORAGE_IMAGE_URL = "https://storage.googleapis.com/openbeta-prod/u"; +const BASE_STORAGE_IMAGE_URL = "https://storage.googleapis.com"; const getImage = (path) => fetch(path).then((res) => res.arrayBuffer()); const getFormat = (webp, avif) => { @@ -19,7 +19,9 @@ app.get("/healthy", (req, res) => { app.get("*", async (req, res) => { try { - const { searchParams, pathname, href } = new URL(req.url.slice(1)); + const { searchParams, pathname, href } = new URL( + `${BASE_STORAGE_IMAGE_URL}${req.url}`, + ); if (!/\.(jpe?g|png|gif|webp)$/i.test(pathname)) { return res.status(400).send("Disallowed file extension"); @@ -38,6 +40,8 @@ app.get("*", async (req, res) => { .resize({ width, height }) .toFormat(format, { quality }); + console.log(pathname, href); + return res .set("Cache-Control", "public, max-age=15552000") .set("Vary", "Accept")