Skip to content

Fix EndpointRequest.toLinks() when base-path is '/'#49191

Open
bbbbooo wants to merge 1 commit intospring-projects:mainfrom
bbbbooo:main
Open

Fix EndpointRequest.toLinks() when base-path is '/'#49191
bbbbooo wants to merge 1 commit intospring-projects:mainfrom
bbbbooo:main

Conversation

@bbbbooo
Copy link

@bbbbooo bbbbooo commented Feb 11, 2026

Problem

When management.endpoints.web.base-path is set to /, it is normalized
to an empty path internally. In this setup, when management runs on a
different port, EndpointRequest.toLinks() never matches.

As a result, security configurations such as
EndpointRequest.toLinks().permitAll() do not work as expected.

This behavior is inconsistent with the actual links endpoint mapping.

Changes

  • Servlet:
    • Use the WebApplicationContext to determine the effective links path.
    • Create a links matcher for / when the management port is different
      and the base path is empty.
  • Reactive:
    • Apply the same links path behavior as the servlet stack.
  • Apply this consistently to:
    • EndpointRequest.toLinks()
    • EndpointRequest.toAnyEndpoint() (links inclusion path)

Tests

Added/updated tests for both servlet and reactive variants to cover:

  • toAnyEndpoint with an empty base path and a different management port
    (links should match)
  • toLinks with an empty base path and a different management port
    (root links matching)

Fixes #34834

When management.endpoints.web.base-path is empty and management runs
on a different port, EndpointRequest.toLinks() and toAnyEndpoint()
do not match the links endpoint consistently.

Derive the links path based on the management port type on both
servlet and reactive sides, and add regression tests for each
implementation.

Fixes spring-projects#34834

Signed-off-by: bbbbooo <hyeons1213@gmail.com>
@bbbbooo bbbbooo changed the title Fix EndpointRequest links matching for separate management port Fix EndpointRequest.toLinks() when base-path is '/' Feb 11, 2026
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EndpointRequest.toLinks() does not match when management.endpoints.web.base-path is '/'

2 participants