"DOMException: Failed to execute 'pushState'" when proxying
Describe the bug
Context
I'm using tan router inside a Vite app which is being proxied too via a Next app (the App Router to be specific). The proxy itself, to the Vite app, seems to work fine before and after the addition of this router. I'm proxying from a subdomain, listen.localhost:3000 to localhost:5001 where the Vite app is hosted.
Problem
When implementing the "Getting Started" guide for the tan router the pathname does not change when switching between /about and /, although the UI does. IN the console I'm shown this error:
chunk-UPNL6TE4.js?v=966f91b5:432 Uncaught (in promise) DOMException: Failed to execute 'pushState' on 'History': A history state object with URL 'http://192.168.1.81:5001/' cannot be created in a document with origin 'http://listen.localhost:3000' and URL 'http://listen.localhost:3000/about'.
at win.history.pushState (http://192.168.1.81:5001/node_modules/.vite/deps/chunk-UPNL6TE4.js?v=966f91b5:432:33)
at http://192.168.1.81:5001/node_modules/.vite/deps/chunk-UPNL6TE4.js?v=966f91b5:376:62
at untrack (http://192.168.1.81:5001/node_modules/.vite/deps/chunk-UPNL6TE4.js?v=966f91b5:369:5)
at flush (http://192.168.1.81:5001/node_modules/.vite/deps/chunk-UPNL6TE4.js?v=966f91b5:373:5)
at http://192.168.1.81:5001/node_modules/.vite/deps/chunk-UPNL6TE4.js?v=966f91b5:398:48
Your Example Website or App
https://github.com/Tommoore96/proxy-spike
Steps to Reproduce the Bug or Issue
- Use
bun installand navigate to each package inapps/using a different terminal and runbun devto get it started. - Open the console and navigate to
listen.localhost:3000. - Click between the "home" and "about" links.
Expected behavior
The pathname in the browser should update on navigation and no error should occur in the console.
Screenshots or Videos
Platform
- OS: macOS
- Browser: Brave
- Version: 1.15.3
Additional context
No response
The console message clearly says what the error is, a history entry with the domain 192.168.1.81 can not be created when the document is loaded from domain listen.localhost.
The domain used to create URLs is probably misconfigured somewhere.
Unlikely that this is a bug in Tanstack Router itself?
I don't think it's that clear as you say yourself that it's "unlikely that this is a bug in Tanstack Router itself" and you think it's "probably misconfigured somewhere". The thing is I don't think it is misconfigured somewhere, everything else works in the app besides Tanstack Router, therefore I opened this issue to see if solution for this to work with Tanstack Router.
Well, all I can suggest is using a debugger to set some break/watchpoints in https://github.com/TanStack/router/blob/21ce1351e5e88d89d8d8924666c4f97251da89ef/packages/history/src/index.ts to figure out how the invalid URL is generated.