Skip to content

fix: respect base path in minified UI HTML - #6227

Merged
alespour merged 4 commits into
masterfrom
fix/issue-6226
Jun 4, 2026
Merged

fix: respect base path in minified UI HTML#6227
alespour merged 4 commits into
masterfrom
fix/issue-6226

Conversation

@alespour

@alespour alespour commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Closes #6226

parcel newer HTML minifier (since v2.15) ) can emit unquoted asset attributes and a boolean data-basepath. The existing prefixer only handled quoted attributes, so UI assets were not rewritten when Chronograf was served under a non-root base path.

This PR updates the prefixer to handle minified src=/..., href=/..., and boolean data-basepath forms while preserving existing quoted behavior.

@alespour alespour changed the title fix: respect base path in minified UI asset HTML fix: respect base path in minified UI HTML Jun 2, 2026

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

Fixes a regression where Chronograf 1.11.x failed to apply BASE_PATH to UI asset URLs in minified HTML produced by parcel ≥ 2.15, which emits unquoted attribute values and a boolean data-basepath attribute. The existing prefixer matched only quoted forms (src=", href=", data-basepath="), leaving minified output unprefixed.

Changes:

  • Add new prefixer attributes for unquoted src=/, href=/, and boolean data-basepath, with handlers that emit the correct prefixed form while preserving protocol-relative (//) URLs.
  • Harden the read loop to handle short reads when priming the buffer, empty windows, and bounds-check the match comparison.
  • Add tests for minified HTML rewriting and a CHANGELOG entry.

Reviewed changes

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

File Description
server/url_prefixer.go Adds match cases for minified src=/, href=/, and boolean data-basepath; bounds-checks subject slicing; restructures main loop to handle EOF and empty buffer safely.
server/url_prefixer_test.go Adds Test_Server_Prefixer_RewritesMinifiedHTML covering unquoted attrs, empty/quoted data-basepath, and a full minified index HTML.
CHANGELOG.md Adds 1.11.4 "unreleased" bug-fix entry linking PR #6227.

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

@alespour
alespour marked this pull request as ready for review June 2, 2026 10:06
@alespour
alespour requested a review from karel-rehor June 2, 2026 10:07
@karel-rehor

karel-rehor commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Smoke test

Built the latest commit (583ff46) locally in cross-builder and started the chronograf binary using the custom path argument -p.

$ ./chronograf --influxdb-v3-support-enabled -p "/foo" -H
INFO[0000] Starting Chronograf testing583ff4617f4cefb803fabdaf3db1c88cec46e698 
INFO[0000] InfluxDB v3 time condition validated and configured  component=server time_condition="time > now() - 1d"
INFO[0000] Serving chronograf at http://[::]:8888        component=server
INFO[0000] Reporting usage stats                         component=usage freq=24h reporting_addr="https://usage.influxdata.com" stats="os,arch,version,cluster_id,uptime"
INFO[0014] Response: Not Found                           component=server method=GET remote_addr="[::1]:56848" response_time="74

After connecting the results to a local instance of Influxdb3 Core, it appears that the resource contexts are working correctly now.

chronograf-583ff461-with-custom-ctx

With ENVARS

N.B. also restarted using ENVARS as described in #6226...

$ export BASE_PATH="/wumpus"
$ export HOST_PAGE_DISABLED=true
$ ./chronograf --influxdb-v3-support-enabled 
INFO[0000] Starting Chronograf testing583ff4617f4cefb803fabdaf3db1c88cec46e698 
INFO[0000] InfluxDB v3 time condition validated and configured  component=server time_condition="time > now() - 1d"
INFO[0000] Serving chronograf at http://[::]:8888        component=server
INFO[0000] Reporting usage stats                         component=usage freq=24h reporting_addr="https://usage.influxdata.com" stats="os,arch,version,cluster_id,uptime"
...

This also works...

chronograf-583ff461-with-custom-ctx-02

@karel-rehor karel-rehor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Manual verification of original issue from build works

Local tests pass.

Changes make sense.

Looks good to me. 🚴 🏁

@alespour
alespour merged commit 235c751 into master Jun 4, 2026
3 checks passed
@alespour
alespour deleted the fix/issue-6226 branch June 4, 2026 12:35
@R290

R290 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Thanks for identifying and resolving the problem! Will this be released asap as part of v1.11.4? I'm stuck for now at v1.10

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.

Chronograf 1.11.2 - ignored BASE_PATH when rendering UI asset paths

4 participants