Skip to content

fix: Make sure that route-prefix does not break the UI#2541

Merged
CommanderStorm merged 6 commits intomaplibre:mainfrom
albing:relative_base
Feb 10, 2026
Merged

fix: Make sure that route-prefix does not break the UI#2541
CommanderStorm merged 6 commits intomaplibre:mainfrom
albing:relative_base

Conversation

@albing
Copy link
Copy Markdown
Contributor

@albing albing commented Feb 6, 2026

Using --route-prefix breaks the UI.

If I start Martin with --route-prefix /martin, I can't use the UI because index.html is always going to reach out to /_/assets/* for its static assets.

Steps to reproduce from the release:

  1. Download and unzip the 1.3.0 release
  2. Run ./martin --webui enable-for-all --route-prefix /martin my.mbtiles
  3. Visit http://localhost:3000/martin/catalog or http://localhost:3000/martin/health : works as expected
  4. Visit http://localhost:3000/martin/ with the inspector open : 404 on
    • /_/assets/index-Cw7_pX04.js
    • /_/assets/maplibre-CAAeTMl5.js

Testing the changes:

  1. In the main branch, just run and see that http://localhost:3000 works
  2. just run --webui enable-for-all --route-prefix /martin and see that it breaks. You might need to set VITE_MARTIN_BASE=http://localhost:3000/martin in .env.local if you have that set.
  3. Check out this branch and run commands 1 and 2 again and see that they both work (making sure to adjust .env.local)

Full disclosure, vite (and frontend in general) isn't my main thing, so I'm not sure if this has greater implications than I realize. Feedback welcome!

This may relate to #2207

@CommanderStorm CommanderStorm changed the title Make the vite base relative fix: Make sure that route-prefix does not break the UI Feb 6, 2026
Copy link
Copy Markdown
Member

@CommanderStorm CommanderStorm left a comment

Choose a reason for hiding this comment

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

I don't think this will work as expected, at least it does not work this way when I run the production bundle:

just run --webui enable-for-all --route-prefix /martin ./tests/fixtures/pmtiles/stamen_toner__raster_CC-BY+ODbL_z3.pmtiles

We don't use vite in prod, so these URLs need to be relative indeed.
Not quite sure how to best handle this.

@CommanderStorm CommanderStorm marked this pull request as draft February 6, 2026 15:48
Copy link
Copy Markdown
Member

@CommanderStorm CommanderStorm left a comment

Choose a reason for hiding this comment

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

Seems to work now mostly.

We still don't support serving the UI at /martin but we support /martin/ now, which is progress.

I also tested the regular base URLs.

@CommanderStorm CommanderStorm marked this pull request as ready for review February 10, 2026 23:01
Copilot AI review requested due to automatic review settings February 10, 2026 23:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where Martin's WebUI breaks when using the --route-prefix configuration option. The issue occurred because static assets (JavaScript bundles, favicon, Open Graph images) used absolute paths starting from the root (/_/assets/*), which didn't account for custom route prefixes.

Changes:

  • Configure Vite to use relative paths for asset references by setting base: './'
  • Update static asset references in index.html to use relative paths
  • Add contributor name to author meta tag (unrelated to the fix)

Reviewed changes

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

File Description
martin/martin-ui/vite.config.ts Added base: './' to make Vite generate relative asset paths that work with any route-prefix
martin/martin-ui/index.html Changed favicon and social media image paths from absolute to relative, plus added contributor to author meta tag

@CommanderStorm CommanderStorm merged commit 9529749 into maplibre:main Feb 10, 2026
46 checks passed
@CommanderStorm CommanderStorm mentioned this pull request Feb 10, 2026
CommanderStorm added a commit that referenced this pull request Feb 11, 2026
## 🤖 New release

* `martin-tile-utils`: 0.6.9 -> 0.6.10 (✓ API compatible changes)
* `mbtiles`: 0.15.1 -> 0.15.2 (✓ API compatible changes)
* `martin-core`: 0.2.6 -> 0.3.0 (⚠ API breaking changes)
* `martin`: 1.3.0 -> 2.0.0

### ⚠ `martin-core` breaking changes

```text
--- failure enum_missing: pub enum removed or renamed ---

Description:
A publicly-visible enum cannot be imported by its prior path. A `pub use` may have been removed, or the enum itself may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/enum_missing.ron

Failed in:
  enum martin_core::config::OptOneMany, previously in file /tmp/.tmpiF3o7Z/martin-core/src/config/cfg_containers.rs:29
  enum martin_core::config::OptBoolObj, previously in file /tmp/.tmpiF3o7Z/martin-core/src/config/cfg_containers.rs:8

--- failure module_missing: pub module removed or renamed ---

Description:
A publicly-visible module cannot be imported by its prior path. A `pub use` may have been removed, or the module may have been renamed, removed, or made non-public.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/module_missing.ron

Failed in:
  mod martin_core::config, previously in file /tmp/.tmpiF3o7Z/martin-core/src/config/mod.rs:1
  mod martin_core::config::env, previously in file /tmp/.tmpiF3o7Z/martin-core/src/config/env.rs:1

--- failure struct_missing: pub struct removed or renamed ---

Description:
A publicly-visible struct cannot be imported by its prior path. A `pub use` may have been removed, or the struct itself may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/struct_missing.ron

Failed in:
  struct martin_core::config::env::OsEnv, previously in file /tmp/.tmpiF3o7Z/martin-core/src/config/env.rs:53
  struct martin_core::config::IdResolver, previously in file /tmp/.tmpiF3o7Z/martin-core/src/config/id_resolver.rs:10
  struct martin_core::config::env::FauxEnv, previously in file /tmp/.tmpiF3o7Z/martin-core/src/config/env.rs:76

--- failure trait_missing: pub trait removed or renamed ---

Description:
A publicly-visible trait cannot be imported by its prior path. A `pub use` may have been removed, or the trait itself may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/trait_missing.ron

Failed in:
  trait martin_core::config::env::Env, previously in file /tmp/.tmpiF3o7Z/martin-core/src/config/env.rs:20
```

<details><summary><i><b>Changelog</b></i></summary><p>


## `mbtiles`

<blockquote>

##
[0.15.2](mbtiles-v0.15.1...mbtiles-v0.15.2)
- 2026-02-11

### Other

- restrict `unused_trait_names` for trait imports
([#2542](#2542))
</blockquote>

## `martin-core`

<blockquote>

##
[0.3.0](martin-core-v0.2.6...martin-core-v0.3.0)
- 2026-02-11

### Added

- *(unstable-cog)* Change tile path semantics for COG sources to match
other sources, expose COG bounds, center and tileSize in TileJSON
([#2510](#2510))

### Other

- *(martin-core)* [**breaking**] remove the configration from the
martin-core crate
([#2521](#2521))
- restrict `unused_trait_names` for trait imports
([#2542](#2542))
</blockquote>

## `martin`

<blockquote>

##
[2.0.0](martin-v1.3.0...martin-v2.0.0)
- 2026-02-11

### Added

- *(srv)* Add HTTP 301 redirects for common URL mistakes
([#2528](#2528))
- *(unstable-cog)* Change tile path semantics for COG sources to match
other sources, expose COG bounds, center and tileSize in TileJSON
([#2510](#2510))

### Fixed

- logs not being integrated with the `path-prefix` correctly
([#2549](#2549))
- Make sure that `route-prefix` does not break the UI when using
trailing slash urls
([#2541](#2541))

### Other

- *(deps)* Bump the all-npm-version-updates group across 2 directories
with 7 updates ([#2553](#2553))
- Add test coverage for header handling in tilejson requests
([#2529](#2529))
- *(martin-core)* [**breaking**] remove the configration from the
martin-core crate
([#2521](#2521))
- *(deps)* autoupdate pre-commit
([#2545](#2545))
- restrict `unused_trait_names` for trait imports
([#2542](#2542))
- *(deps)* Bump the all-npm-version-updates group across 2 directories
with 12 updates ([#2533](#2533))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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.

3 participants