Closed bbourn closed 1 year ago
So right now I am using the pushRoute('/prefix-dir/Homepage/') syntax as it errors out, then loads the page anyway (shallow) with the proper url... Which works in chrome for now but not in Safari.
I was having the same issue as you, and found this comment to offer a viable workaround: https://github.com/fridays/next-routes/issues/30#issuecomment-383368319
@LaurentVBk, @stanleyfok THANK YOU SO MUCH!!! That worked beautifully!
We are using assetPrefix and have next setup to serve on a sub-folder. On initial load our pages router object has: asPath:"/prefix-dir/Homepage/[old param name]" pathname and route are both "/homepage" query has [old param name] And page load as it should. Everything works fine.
Then we navigate to a new by calling:
Router.pushRoute("/Homepage/[new param name]")
And now that same pages router object has:
asPath:"/Homepage/[new param name]" <---- without the needed /prefix-dir
pathname and route are both "/homepage"
query has [new param name]
How can I preserve the assetPrefix in the asPath? If I put it in the Router.pushRoute("/prefix-dir/Homepage/[new param name]") statement, I get net::ERR_ABORTED 404 on the _next/static/development/pages/pages/prefix-dir/Homepage/[new param name].js url because there isn't a sub-dir in pages, and the parameter isn't a page.
If I use Router.pushRoute("/Homepage/[new param name]") everything is fine, accept if they hit refresh on the page, the get an 'Cannot GET /Homepage' error because that page doesn't exist without the /prefix-dir.
If I leave off the beginning '/' I get: Uncaught (in promise) Error: Route name should start with a "/",
How can I get Router.pushRoute to set asPath with the prefix-dir prepended?