Repository navigation
fix(client): rewrite absolute fetch/EventSource paths under basePath - #8515
Merged
diegosouzapw merged 7 commits intoJul 28, 2026
Merged
diegosouzapw merged 7 commits into
diegosouzapw merged 7 commits into
Conversation
Absolute browser calls like fetch("/api/...") and new EventSource("/api/...")
do not honor Next.js basePath, so subpath deploys (OMNIROUTE_BASE_PATH) break
dashboard health checks, settings APIs, and SSE unless a reverse proxy rewrites
the domain root.
- Add withBasePath / getDeployBasePath helpers
- Install ref-counted fetch + EventSource rewrite when basePath is set
(same pattern as installDashboardCsrfFetch)
- Mount BasePathNetworkProvider at the root so login works too
- Mirror OMNIROUTE_BASE_PATH to NEXT_PUBLIC_OMNIROUTE_BASE_PATH for the client
- Document in .env.example; unit tests for rewrite rules
…ll-shape asserts Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
…et and fix basePath TS2322 Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
# Conflicts: # next.config.mjs
diegosouzapw
merged commit Jul 28, 2026
8e5dc0d
into
cheaper-inference:release/v3.8.49
5 checks passed
Merged
HouMinXi
pushed a commit
to HouMinXi/OmniRoute
that referenced
this pull request
Aug 2, 2026
…heaper-inference#8515) * fix(client): rewrite absolute fetch/EventSource paths under basePath Absolute browser calls like fetch("/api/...") and new EventSource("/api/...") do not honor Next.js basePath, so subpath deploys (OMNIROUTE_BASE_PATH) break dashboard health checks, settings APIs, and SSE unless a reverse proxy rewrites the domain root. - Add withBasePath / getDeployBasePath helpers - Install ref-counted fetch + EventSource rewrite when basePath is set (same pattern as installDashboardCsrfFetch) - Mount BasePathNetworkProvider at the root so login works too - Mirror OMNIROUTE_BASE_PATH to NEXT_PUBLIC_OMNIROUTE_BASE_PATH for the client - Document in .env.example; unit tests for rewrite rules * docs(changelog): add fragment for cheaper-inference#8515 basePath client fetch * test(client): move basePath tests into a scanned dir and fix no-op call-shape asserts Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> * fix(client-sweep-8515): restore CHANGELOG cheaper-inference#8471 bullet and fix basePath TS2322 Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> --------- Co-authored-by: rqzbeh <rqzbeh@users.noreply.github.com> Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> Co-authored-by: Diego Rodrigues de Sa e Souza <diegosouza.pw@gmail.com> Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com>
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…heaper-inference#8515) * fix(client): rewrite absolute fetch/EventSource paths under basePath Absolute browser calls like fetch("/api/...") and new EventSource("/api/...") do not honor Next.js basePath, so subpath deploys (OMNIROUTE_BASE_PATH) break dashboard health checks, settings APIs, and SSE unless a reverse proxy rewrites the domain root. - Add withBasePath / getDeployBasePath helpers - Install ref-counted fetch + EventSource rewrite when basePath is set (same pattern as installDashboardCsrfFetch) - Mount BasePathNetworkProvider at the root so login works too - Mirror OMNIROUTE_BASE_PATH to NEXT_PUBLIC_OMNIROUTE_BASE_PATH for the client - Document in .env.example; unit tests for rewrite rules * docs(changelog): add fragment for cheaper-inference#8515 basePath client fetch * test(client): move basePath tests into a scanned dir and fix no-op call-shape asserts Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> * fix(client-sweep-8515): restore CHANGELOG cheaper-inference#8471 bullet and fix basePath TS2322 Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> --------- Co-authored-by: rqzbeh <rqzbeh@users.noreply.github.com> Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> Co-authored-by: Diego Rodrigues de Sa e Souza <diegosouza.pw@gmail.com> Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When OmniRoute is served under a reverse-proxy subpath (
OMNIROUTE_BASE_PATH=/omniroute), absolute client calls:hit
https://host/api/...instead ofhttps://host/omniroute/api/....That breaks the maintenance banner, dashboard APIs, SSE log streams, and login bootstrap unless nginx rewrites
/apiand/v1at the edge.Next.js rewrites
Link/useRouterforbasePath, but not the Fetch / EventSource APIs.Approach
Mirror the existing
installDashboardCsrfFetchpattern:withBasePath()— pure helper for absolute paths and same-origin absolute URLsinstallBasePathFetch()— ref-counted wrap ofglobalThis.fetch+window.EventSourcewhen basePath is non-empty (no-op on root deploys)BasePathNetworkProvidermounted in the root layout (covers login + dashboard)next.config.mjsmirrorsOMNIROUTE_BASE_PATH→NEXT_PUBLIC_OMNIROUTE_BASE_PATHfor the client bundleNo authz changes. Root deploys unchanged (empty basePath → install is a no-op).
Related
/v1vs/omniroute/v1): fix(dashboard): include OMNIROUTE_BASE_PATH in displayed API base URL #8514Test plan
OMNIROUTE_BASE_PATH=/omniroute):/apirewritevitest run src/shared/utils/__tests__/basePath.test.ts src/shared/utils/__tests__/basePathFetch.test.ts