Comments (10)
And solved! Posting here in case someone else is running into the same issue. vercel/next.js#45886 (comment)
from platforms.
Hey @minardimedia! So sorry for the late response – this should've been fixed with our new middleware here. Please try it out and let me know if it works!
I'll close this issue for now but feel free to reopen it if there are any other issues!
from platforms.
Hey @steven-tey, just so you know I'm currently running into this issue ([email protected]
).
Using both shallow and non-shallow routing, I'm experiencing the same behaviour as above.
Any ideas on how to resolve this?
from platforms.
@steven-tey, as far as I can tell, the issue doesn’t seem to be with the middleware, but with the router
handler.
- Middleware
rewrites
a path to a hidden folder (e.g./_sites/[site]
) - Router pushes a shallow update to the queries, and it results in
/_sites/[site]?somequery=true
appearing in the URL.
How does one do a shallow router push considering the hidden folder?
Note: if I do something like router.push({ pathname: router.pathname.replace('/_sites/[site]', '')
it then ends up constantly reloading the page.
from platforms.
@minardimedia and @sinclairnick were you able to resolve this? It’s driving me stark mad... spent an entire day on this so far, with no solution in sight.
from platforms.
@heymartinadams I think at the end I didn't use the router push I think the reason I wanted to implement this was so I can persist the url state in the query. So I use a library called Jotai they have a couple cool ways to store the data and read data from the url if I am not wrong I use the atomWithHash() hook so at the end I just use the < Link > component and form the url string like this
href = `/room/${room.id}/book#${guestsStringQuery(
guests
)}&check_in=${checkIn.format("YYYY-MM-DD")}&check_out=${checkOut.format(
"YYYY-MM-DD"
)}`;
So there is a store that keeps in sync check_in check_out data
Here is the library Jotai Location hope this can help in your use case
from platforms.
Thank you, @minardimedia! I'll use that library if I can't get router.push
to work.
from platforms.
@steven-tey do you think this issue is merely due to an incorrect configuration of middleware, or a flaw in router
when combined with middleware and subdomains?
From what I can tell, router.push({ query: { site: 'mysubdomain', price: 'mfi49o' } }, undefined, { shallow: true })
does not engage middleware to rewrite
, which causes the URL to display: mysubdomain.localhost:3000/_sites/mysubdomain/
. This may be intentional (i.e. not invoking use of middleware), but defeats the URL masking.
If I do router.push('http://mysubdomain.localhost:3000/?price=mfi49o', undefined, { shallow: true })
in order to hide /_sites/[site]
then the URL does a complete reload.
from platforms.
@steven-tey I posted this issue, with reproduction, on the main next
site, because the issue does indeed seem to lie with next/router
. vercel/next.js#45886
from platforms.
I have a similar setup to this repo but I'm using the app directory. It doesn't seem like the router imported from next/navigation
supports shallow routing. Any hint to solve that?
cc @steven-tey I see that you've started to have a look at moving to the app directory in #161
from platforms.
Related Issues (20)
- Adding NextAuth
- Bug: Adding a custom domain with an initial misconfigured DNS config keeps staying in error mode forever
- request headers host unexpectedly changed
- Error when deploying Django App on Vercel
- How to load different UI configurations based on the tenant? HOT 5
- how to invalidate all a pages of a [domain] route
- Title and description fields within the post editor do not trigger the save function as expected, also infinite loop on editor page related to nav.tsx HOT 4
- How to get this to work with next-auth v5? HOT 3
- Support for internationalization HOT 3
- When accessing blog created on localhost, it returns 404 how do I solve this HOT 2
- Edge function Error : ERR_MODULE_NOT_FOUND on an installed module HOT 1
- Errors are not showing on login page because of redirects in middleware HOT 1
- minor: (invalid?) use of promises HOT 1
- Stuck on "add your root domain & wildcard domain." from guide HOT 3
- Bug: able to create sites with blank site name & description HOT 1
- Use custom domain for Preview Deployments
- can we use platforms without vercel HOT 2
- Adding custom domains without relying on subdomains
- Feature Request: "teams/orgs" support
- RFC: Revert all edge rendering back to Node.js
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from platforms.