fix(nuxt): guard window access

This commit is contained in:
Daniel Roe 2024-12-09 15:19:10 +00:00
parent 54f5b9e8a4
commit d874726ffb
No known key found for this signature in database
GPG Key ID: 3714AB03996F442B

View File

@ -29,7 +29,9 @@ export default defineNuxtRouteMiddleware(async (to) => {
// We pretend to have navigated to the invalid route so // We pretend to have navigated to the invalid route so
// that the user can return to the previous page with // that the user can return to the previous page with
// the back button. // the back button.
window?.history.pushState({}, '', to.fullPath) if (typeof window !== 'undefined') {
window.history.pushState({}, '', to.fullPath)
}
}) })
// We stop the navigation immediately before it resolves // We stop the navigation immediately before it resolves
// if there is no other route matching it. // if there is no other route matching it.