diff --git a/.github/workflows/deploy-staging.yml b/.github/workflows/deploy-staging.yml index 0ee8179..e4c78bd 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-staging - 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)) {