-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doesn't consider basePath? #78
Comments
I can't reproduce it in the examples given, but it's definitely causing weird artifacts in my app. Like redundantly duplicating basePath "/frontend/frontend/...", and subsequently redirecting to it which obviously results in 404. I can't yet figure out why or where this is happening, or whether its my own app or this library... But I've found a workaround that seems to avoid the issue of unnecessary redirection and path changes. By patching import Router from 'next/router'
import { createRouterMiddleware, ConnectedRouter } from 'connected-next-router';
/* Make `Router.asPath` return with `basePath` prefixed (if absent) */
const patchedRouter = new Proxy(Router, {
get: (Router, key, receiver) => {
if (key === 'asPath') {
const { basePath, asPath } = Router
const replaced = asPath.includes(basePath) ? asPath : basePath + asPath
return replaced
} else {
return Reflect.get(Router, key, receiver)
}
}
})
createRouterMiddleware({ Router: patchedRouter })
<ConnectedRouter Router={patchedRouter}/> |
Hi @laggingreflex, I'm currently sick and can't investigate the issue at the moment. I should be able to next week. |
I'm also seeing this behavior, but only when using query parameters. Otherwise great work! |
Does this not take basePath into consideration?
I have "/frontend" as my
basePath
and I'm seeing this in the logs (using redux-logger):Not sure what the expected behaviour should be, but:
Should this route change even register, since they're basically the same paths?
Should "/frontend" either be added to, or omitted from both before-and after-states?
Great module BTW!
The text was updated successfully, but these errors were encountered: