From 5e621d5da557cc1f9ee1de33df7264208a8fb283 Mon Sep 17 00:00:00 2001 From: Iacami Gevaerd Date: Fri, 3 Nov 2023 11:48:55 -0300 Subject: [PATCH] incorporating base bucket url --- .github/workflows/deploy-staging.yml | 2 ++ app.js | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-staging.yml b/.github/workflows/deploy-staging.yml index 0ee8179..7fe778f 100644 --- a/.github/workflows/deploy-staging.yml +++ b/.github/workflows/deploy-staging.yml @@ -41,6 +41,8 @@ jobs: with: service: "staging-media-server" image: "vnguyen/openbeta-media-server:staging" + env_vars: | + STORAGE_BUCKET=openbeta - name: "Use output" run: 'curl "${{ steps.deploy.outputs.url }}"' diff --git a/app.js b/app.js index 10e858b..521543c 100644 --- a/app.js +++ b/app.js @@ -6,7 +6,8 @@ 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"; +const BASE_STORAGE_IMAGE_URL = "https://storage.googleapis.com/"; +const BUCKET = process.env.STORAGE_BUCKET || "openbeta-prod"; const getImage = (path) => fetch(path).then(async (r) => ({ @@ -24,7 +25,7 @@ app.get("/healthy", (req, res) => { app.get("*", async (req, res) => { try { const { searchParams, pathname, href } = new URL( - `${BASE_STORAGE_IMAGE_URL}${req.url}`, + `${BASE_STORAGE_IMAGE_URL}${BUCKET}${req.url}`, ); if (!/\.(jpe?g|png|gif|webp)$/i.test(pathname)) {