Skip to content

fix(storage): honor MINIO_PUBLIC_URL for browser-facing object URLs#1102

Merged
amhsirak merged 1 commit into
getmaxun:developfrom
Osamaali313:fix/minio-public-url
Jun 24, 2026
Merged

fix(storage): honor MINIO_PUBLIC_URL for browser-facing object URLs#1102
amhsirak merged 1 commit into
getmaxun:developfrom
Osamaali313:fix/minio-public-url

Conversation

@Osamaali313

@Osamaali313 Osamaali313 commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Description

Stored screenshots/files never load on any deployment where MinIO is not reachable at localhost:9000 from the browser (reverse proxy, separate host, or a non-default public port).

Root cause

In server/src/storage/mino.ts, the browser-facing object URL written to a run's binaryOutput was composed from the internal MinIO host/port:

const publicHost = process.env.MINIO_PUBLIC_HOST || 'http://localhost';
const publicPort = process.env.MINIO_PORT || '9000';
const publicUrl = `${publicHost}:${publicPort}/${this.bucketName}/${minioKey}`;

MINIO_PORT is the internal MinIO port used for the minio client connection, and the host defaults to localhost. So in a typical Docker/proxied deploy the generated URLs point at localhost:9000 (or force :9000 onto a proxied host like https://storage.example.com:9000/...), which the browser cannot reach — the screenshots silently 404. This matches the report in #832.

Fix

Prefer a complete public base URL via a new optional MINIO_PUBLIC_URL, and only fall back to the existing MINIO_PUBLIC_HOST:MINIO_PORT composition when it is not set:

const publicBase = (
  process.env.MINIO_PUBLIC_URL
    ? process.env.MINIO_PUBLIC_URL
    : `${process.env.MINIO_PUBLIC_HOST || 'http://localhost'}:${process.env.MINIO_PORT || '9000'}`
).replace(/\/+$/, '');
const publicUrl = `${publicBase}/${this.bucketName}/${minioKey}`;
  • Non-breaking: with no new env var set, the output is byte-for-byte identical to before (verified for the default and MINIO_PUBLIC_HOST+MINIO_PORT cases).
  • Deployments behind a proxy can now set MINIO_PUBLIC_URL=https://storage.example.com and get correct, reachable URLs (no internal port appended).
  • Documents the variable in ENVEXAMPLE.

Fixes #832

Testing

No automated test suite exists in the repo, so I verified the URL-building logic in isolation across cases:

Env Output
(default) http://localhost:9000/<bucket>/<key> (unchanged)
MINIO_PUBLIC_HOST=http://1.2.3.4, MINIO_PORT=9000 http://1.2.3.4:9000/<bucket>/<key> (unchanged)
MINIO_PUBLIC_URL=https://storage.example.com https://storage.example.com/<bucket>/<key> (fixed)
MINIO_PUBLIC_URL=https://storage.example.com/ trailing slash stripped → correct

Summary by CodeRabbit

  • New Features

    • MinIO now supports optional configurable public URL setting, enabling reverse-proxy and non-localhost deployment scenarios
    • System automatically falls back to default host/port configuration when custom URL is not provided
  • Documentation

    • Added configuration documentation and setup instructions for MinIO public URL deployments

Screenshot/file URLs written to a run's binaryOutput were built from the
internal MinIO host/port (defaulting to localhost:9000). Any deployment
where MinIO sits behind a reverse proxy or on a non-localhost public
address produced unreachable URLs, so stored screenshots never loaded.

Prefer a complete public base URL via MINIO_PUBLIC_URL (e.g.
https://storage.example.com) and fall back to the existing
MINIO_PUBLIC_HOST:MINIO_PORT composition for local/dev setups, so existing
configurations are byte-for-byte unchanged. Documents the variable in ENVEXAMPLE.

Fixes getmaxun#832
Copilot AI review requested due to automatic review settings June 13, 2026 21:10
@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 66fb957c-8939-447d-9269-b3c18e23214d

📥 Commits

Reviewing files that changed from the base of the PR and between 50ee9b3 and 755e768.

📒 Files selected for processing (2)
  • ENVEXAMPLE
  • server/src/storage/mino.ts

Walkthrough

This PR enables configurable MinIO public URLs in self-hosted deployments behind reverse proxies. The ENVEXAMPLE file documents the new optional MINIO_PUBLIC_URL setting, and server/src/storage/mino.ts updates binary output URL construction to prefer MINIO_PUBLIC_URL when available, falling back to host/port composition.

Changes

MinIO Public URL Configuration

Layer / File(s) Summary
MinIO public URL configuration and implementation
ENVEXAMPLE, server/src/storage/mino.ts
Environment variable documentation for MINIO_PUBLIC_URL guides reverse-proxy deployments. Service implementation in BinaryOutputService.uploadAndStoreBinaryOutput constructs browser-facing URLs using the environment variable (trimmed of trailing slashes) or falls back to the host/port composition.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

Scope: Documentation

Poem

🐰 A proxy stands between the cloud and thee,
MinIO URLs now roam wild and free,
No more locked to localhost's cage,
Configure your domain on this glorious page!
Screenshots soar where they should be. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately summarizes the main change: honoring a new MINIO_PUBLIC_URL configuration for constructing browser-facing object URLs, which is the core fix in the PR.
Linked Issues check ✅ Passed The PR implements the fix for issue #832 by introducing MINIO_PUBLIC_URL support, allowing deployments to configure public-facing MinIO URLs so screenshots display correctly in distributed setups.
Out of Scope Changes check ✅ Passed All changes are scoped to resolving the linked issue: ENVEXAMPLE documents the new setting, and minio.ts implements the URL construction logic with fallback behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds support for a configurable browser-facing MinIO base URL to avoid generating unreachable localhost:9000 links in proxied/non-default deployments.

Changes:

  • Build public object URLs from MINIO_PUBLIC_URL when set, with fallback to MINIO_PUBLIC_HOST + MINIO_PORT.
  • Trim trailing slashes from the configured public base before concatenating path segments.
  • Document the new MINIO_PUBLIC_URL variable in ENVEXAMPLE.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
server/src/storage/mino.ts Prefer a fully specified public base URL for generated object links, with normalization and fallback behavior.
ENVEXAMPLE Documents MINIO_PUBLIC_URL for reverse-proxy/public-endpoint setups.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +174 to +179
const publicBase = (
process.env.MINIO_PUBLIC_URL
? process.env.MINIO_PUBLIC_URL
: `${process.env.MINIO_PUBLIC_HOST || 'http://localhost'}:${process.env.MINIO_PORT || '9000'}`
).replace(/\/+$/, '');
const publicUrl = `${publicBase}/${this.bucketName}/${minioKey}`;
Comment thread ENVEXAMPLE
Comment on lines +17 to +20
# Public base URL browsers use to reach stored screenshots/files. Set this when
# MinIO is behind a reverse proxy or on a non-localhost/non-9000 public address,
# e.g. https://storage.example.com (no internal port appended). Optional.
# MINIO_PUBLIC_URL=https://storage.example.com
@amhsirak amhsirak requested a review from RohitR311 June 16, 2026 21:45

@amhsirak amhsirak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Osamaali313 lgtm - thanks! 🙌

@amhsirak amhsirak merged commit fd3f01e into getmaxun:develop Jun 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Recorded screenshots do not load on frontend due to wrong URL

4 participants