-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
router push gives DOMException: Failed to execute 'replace' on 'Location': 'http://localhost:8080undefined' is not a valid URL #366
Comments
Hello, thank you for taking time filling this issue! However, we kindly ask you to use our Issue Helper when creating new issues, in order to ensure every issue provides the necessary information for us to investigate. This explains why your issue has been automatically closed by me (your robot friend!). I hope to see your helper-created issue very soon! |
@leopsidom Did you figure it out? I'm getting the same error when calling |
If you manage to reproduce, please open a new issue! Calling history.replaceState(history.state, '', ...) |
@posva Thanks a lot, that did the trick. I was doing |
I'm interested in the use cases for manually calling |
@posva I think a common use case is saving form values or pagination info in the history (as query string) so you can go back, refresh or link to that page while keeping the form state. I remember checking this in the previous router but could not find a way to do it properly so I had to modify the history manually. Not sure if there's a way to do it in the current version of the router, I haven't tried since I'm just upgrading the existing code to Vue 3. |
Even though it's not documented, you can now pass a You can natively save state with I thought the form state was automatically saved by browsers 😄 I think, being able to pass |
For me, this issue still exists. Basically |
@leopsidom I won't be able to help if you don't provide a boiled down reproduction 🙂 |
Hmm, I was not able to reproduce it from scratch. Maybe it's a vue cli issue. Previously I did |
Okay, I think I got why this is happening. This happens when my website is redirected. For instance, I use a third party authentication service where I'm redirected from domain A to domain B to do authentication and after login, I'm redirected back to domain A. Here if I don't refresh the page and simply do a |
Finally figure out the issue, I was using |
@leopsidom that's a bug on the library, they should keep the current state at https://github.com/aws-amplify/amplify-js/blob/main/packages/auth/src/Auth.ts#L1942 window.history.replaceState(
window.history.state,
'',
(this._config.oauth as AwsCognitoOAuthOpts).redirectSignIn
); Even if a gracefully handle it, it will break other features of Vue Router and create inconsistent situations. In other words, it will break elsewhere. I've been testing different interactions and they become inconsistent. I will still put up a PR because it's better than having an error. But I think, the best would be to have a warn |
why this problem is still confused me |
Workaround: if you use const new_state = {
whatever: 'this is your data',
current: '/' // this is the workaround
}
window.history.pushState(new_state, '', '/next/path'); What was the problems? |
Using
router.push(path)
but get an error as in the title. When looking at the debugger, it fails at thechangeLocation
line:I can see in the debugger that
to
has the correct value butcurrentState.current
is undefined. What could be the issue?The text was updated successfully, but these errors were encountered: