Files
openclaw/extensions/matrix/src
Papilionidae 0680dfc6a9 fix(matrix): reverse-proxy path support for Matrix homeserver URLs (#93516)
* feat(matrix): add configurable apiPrefix for non-standard homeserver API paths

* fix(matrix): remove public apiPrefix config, keep transport path fix

The apiPrefix config surface was incomplete: it was not carried through
resolveMatrixConfigForAccount, MatrixAuth, shared client keying, or
createMatrixClient, making it a no-op in normal runtime paths.

Following ClawSweeper review direction, this narrow fix:
- Removes apiPrefix from MatrixConfigSchema and MatrixConfig types
- Keeps apiPrefix as a private internal constant in MatrixAuthedHttpClient
  for bare-path resolution (DEFAULT_API_PREFIX = /_matrix/client/v3)
- Stops MatrixClient from accepting/passing apiPrefix
- Retains the transport.ts normalizeEndpoint() fix for homeserver URLs
  behind reverse proxies (avoids losing path segments on trailing-slash
  mismatches)

Test: 1393 tests pass across 121 matrix extension test files.

* fix(matrix): ensure homeserver URL ends with slash for new URL() resolution

Without a trailing slash, new URL(relPath, homeserver) treats the final
path segment as a filename, losing the reverse-proxy prefix path.

For example:
  new URL('_matrix/...', 'https://host/proxy')
  -> https://host/_matrix/... (wrong, 'proxy' dropped)

With trailing slash:
  new URL('_matrix/...', 'https://host/proxy/')
  -> https://host/proxy/_matrix/... (correct)

* test(matrix): add URL resolution coverage for path-prefixed homeservers

* fix(matrix): preserve reverse-proxy homeserver paths

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-07-27 05:25:58 -04:00
..