Skip to content

Fix _extract_base_url stripping context path for Server/DC instances#168

Merged
Spenhouet merged 1 commit intoSpenhouet:mainfrom
MathurinV:fix/server-dc-context-path-in-base-url
Apr 7, 2026
Merged

Fix _extract_base_url stripping context path for Server/DC instances#168
Spenhouet merged 1 commit intoSpenhouet:mainfrom
MathurinV:fix/server-dc-context-path-in-base-url

Conversation

@MathurinV
Copy link
Copy Markdown

Summary

Server/Data Center instances deployed under a context path (e.g. /confluence) need that path preserved in the base URL for correct SDK endpoint resolution and auth config lookup.

The fix splits the URL path into segments and stops at the first known Confluence route segment (wiki, display, spaces, rest, pages, plugins, dosearchsite.action), keeping everything before it as the context path. Cloud URLs (*.atlassian.net) and API gateway URLs are unaffected.

Fixes #167

Test Plan

  • All 172 existing tests pass
  • Verified manually against https://host/confluence/spaces/KEY → extracts https://host/confluence
  • Verified Cloud URLs (company.atlassian.net/wiki/spaces/KEY) still extract https://company.atlassian.net
  • Verified port preservation (host:8090/confluence/display/PROJ) → https://host:8090/confluence
  • Verified nested context paths (host/myapp/confluence/wiki/spaces/KEY) → https://host/myapp/confluence

Server/Data Center instances deployed under a context path (e.g.
/confluence) need that path preserved in the base URL for correct
SDK endpoint resolution and auth config lookup.

Split URL path into segments and stop at the first known Confluence
route segment (wiki, display, spaces, rest, etc.), keeping everything
before it as the context path.
@MathurinV MathurinV force-pushed the fix/server-dc-context-path-in-base-url branch from 3d4a86d to 0046360 Compare April 7, 2026 10:00
@Spenhouet Spenhouet merged commit 176110c into Spenhouet:main Apr 7, 2026
1 check passed
@Spenhouet
Copy link
Copy Markdown
Owner

@MathurinV Thanks for your PR!

@Spenhouet
Copy link
Copy Markdown
Owner

@MathurinV Just a note: I tested

host:8090/confluence/display/PROJ

and it will parse "host" as the schema, which will not work when constructing the URL.

I don't think that's a big issue but your Test Plan stated

Verified port preservation (host:8090/confluence/display/PROJ) → https://host:8090/confluence

so it might be something you expected to work?

@Spenhouet
Copy link
Copy Markdown
Owner

@MathurinV I pushed some further improvements to provide more guidance on providing a correct URL in version 4.0.3. Please check it out.

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.

Server/DC context path stripped by _extract_base_url, breaking auth and API calls

2 participants