diff --git a/.changeset/neat-spies-spend.md b/.changeset/neat-spies-spend.md new file mode 100644 index 00000000..f643437e --- /dev/null +++ b/.changeset/neat-spies-spend.md @@ -0,0 +1,5 @@ +--- +'@tanstack/devtools': patch +--- + +fixed an issue where SourceInspector was not working when the app is served to a subpath diff --git a/packages/devtools/src/components/source-inspector.tsx b/packages/devtools/src/components/source-inspector.tsx index 88fb58ea..b5f51ecb 100644 --- a/packages/devtools/src/components/source-inspector.tsx +++ b/packages/devtools/src/components/source-inspector.tsx @@ -78,11 +78,15 @@ export const SourceInspector = () => { e.preventDefault() e.stopPropagation() - fetch( - `${location.origin}/__tsd/open-source?source=${encodeURIComponent( + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + const baseUrl = new URL(import.meta.env?.BASE_URL ?? '/', location.origin) + const url = new URL( + `__tsd/open-source?source=${encodeURIComponent( highlightState.dataSource, )}`, - ).catch(() => {}) + baseUrl, + ) + fetch(url).catch(() => {}) }) const currentElementBoxStyles = createMemo(() => {