Skip to content

fix: redirect ignoring --route-prefix for .pbf tile requests#2599

Merged
CommanderStorm merged 2 commits intomaplibre:mainfrom
Paritoshcodes:fix-route-prefix-redirect
Mar 13, 2026
Merged

fix: redirect ignoring --route-prefix for .pbf tile requests#2599
CommanderStorm merged 2 commits intomaplibre:mainfrom
Paritoshcodes:fix-route-prefix-redirect

Conversation

@Paritoshcodes
Copy link
Contributor

Fixes #2596

Ensure redirect URLs include the configured route prefix when handling
.pbf tile requests behind a reverse proxy.

Previously the redirect logic constructed URLs without the route prefix,
causing incorrect redirects when Martin was deployed behind a reverse proxy.

This change prepends the configured route prefix to the redirect
Location header.

A regression test was added to verify correct behavior.

Copy link
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

Fixes a redirect bug in Martin’s tile endpoints where requests to *.pbf (and other *.{ext} tile routes) produced a Location header that ignored the configured --route-prefix, breaking deployments behind reverse proxies.

Changes:

  • Include SrvConfig.route_prefix when building the redirect Location for tile redirects (preserving query string).
  • Add an integration test asserting the redirect Location includes the configured prefix for .pbf tile requests.

Reviewed changes

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

File Description
martin/src/srv/tiles/content.rs Passes route_prefix into the redirect helper so Location includes the configured mount path.
martin/tests/route_prefix_test.rs Adds regression test verifying redirect Location includes the route prefix and preserves query params.

You can also share your feedback on Copilot code review. Take the survey.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@CommanderStorm CommanderStorm changed the title Fix redirect ignoring --route-prefix for .pbf tile requests fix: redirect ignoring --route-prefix for .pbf tile requests Mar 13, 2026
Copy link
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.

Thanks for the bugfix! 🎉

@CommanderStorm CommanderStorm enabled auto-merge (squash) March 13, 2026 08:09
@c-meier
Copy link

c-meier commented Mar 13, 2026

Shouldn't the same thing be done for the pluralization redirect handlers (styles→style, sprites→sprite, etc.) created by #2528 ?

And, if I understand the doc correctly, the base_path config parameter can also change the Location of the redirect for the tile api.

@Paritoshcodes
Copy link
Contributor Author

Hello @c-meier, that is a good point but my fix currently only handles the .pbf redirect path, but I agree the same logic may need to be applied to the pluralization redirect handlers as well. I can take a look at that after this PR is merged if needed.

@CommanderStorm CommanderStorm merged commit a69034a into maplibre:main Mar 13, 2026
40 of 41 checks passed
@CommanderStorm CommanderStorm mentioned this pull request Mar 11, 2026
CommanderStorm added a commit that referenced this pull request Mar 15, 2026
## 🤖 New release

* `martin-tile-utils`: 0.6.10 -> 0.6.11 (✓ API compatible changes)
* `mbtiles`: 0.15.2 -> 0.15.3 (✓ API compatible changes)
* `martin-core`: 0.3.0 -> 0.3.1 (✓ API compatible changes)
* `martin`: 1.3.1 -> 1.4.0

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


## `mbtiles`

<blockquote>

##
[0.15.3](mbtiles-v0.15.2...mbtiles-v0.15.3)
- 2026-03-14

### Added

- *(srv)* resolve some compression TODOS
([#2597](#2597))

### Fixed

- Accept any INT-containing type in MBTiles validation to be an integer
([#2560](#2560))

### Other

- rename the `webp.sql` fixture to `webp-no-primary.sql`
([#2564](#2564))
- More restrictive expects
([#2562](#2562))
</blockquote>

## `martin-core`

<blockquote>

##
[0.3.1](martin-core-v0.3.0...martin-core-v0.3.1)
- 2026-03-14

### Added

- Add retry mechanism on locked/busy mbtiles files
([#2572](#2572))

### Other

- More restrictive expects
([#2562](#2562))
- feature-gate PostgreSQL tests to remove external dependencies from
`cargo test` ([#2558](#2558))
</blockquote>

## `martin`

<blockquote>

##
[1.4.0](martin-v1.3.1...martin-v1.4.0)
- 2026-03-14

### Added

- *(srv)* resolve some compression TODOS
([#2597](#2597))
- Migrate mdbooks to zensical
([#2576](#2576))
- *(martin-cp)* indicativ based progress bar
([#2495](#2495))
- Add retry mechanism on locked/busy mbtiles files
([#2572](#2572))

### Fixed

- *(ui)* render MLT tiles correctly in Tile Inspector
([#2601](#2601))
- redirect ignoring `--route-prefix` for .pbf tile requests
([#2599](#2599))
- restrict zooming and panning on data inspector
([#2574](#2574))
- Accept any INT-containing type in MBTiles validation to be an integer
([#2560](#2560))

### Other

- *(deps)* Bump the all-npm-version-updates group across 2 directories
with 9 updates ([#2608](#2608))
- *(deps-dev)* Bump undici from 7.21.0 to 7.24.1 in /martin/martin-ui in
the all-npm-security-updates group across 1 directory
([#2602](#2602))
- *(deps)* autoupdate pre-commit
([#2592](#2592))
- *(deps)* Bump the all-npm-version-updates group across 2 directories
with 13 updates ([#2577](#2577))
- *(deps)* Bump the all-npm-security-updates group across 2 directories
with 1 update ([#2575](#2575))
- *(deps)* autoupdate pre-commit
([#2567](#2567))
- rename the `webp.sql` fixture to `webp-no-primary.sql`
([#2564](#2564))
- more cfg magic instead of #[allow(unused_variables)]
([#2563](#2563))
- More restrictive expects
([#2562](#2562))
- feature-gate PostgreSQL tests to remove external dependencies from
`cargo test` ([#2558](#2558))
</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.

301 redirect ignores --route-prefix, breaking requests behind a reverse proxy

4 participants