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")