router.push() with rewrites for ISR experiment/feature flags #77521
Unanswered
matt-halliday
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
We are rolling out variants across our site (Next 15, PageRouter, ISR, OpenNext). This involves a middleware decision using Optimizely, which then adds
__variation/flag-a:variation-1
or similar to the end of the URL and returns aNextResponse.rewrite()
.This is working well on catchAll routes and simple pages. On more complex interfaces like search, we use
router.push
to represent the managed state in the URL query. This is a problem and throws an error thatrouteInfo is undefined
because the pathname on the router push is a page that exists... there is a caveat explaining this isn't possible with a shallow push.Is there a way to handle this?
Additional information
The
[variant].tsx
page takes the request when there's an experiment running, and therouter.push
cannot succeed because we're pushing/search
and a page for that route exists.Beta Was this translation helpful? Give feedback.
All reactions