mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-16 13:48:13 +00:00
fix(nuxt): normalise window location for universal router (#4841)
This commit is contained in:
parent
750460693e
commit
b29f635646
@ -1,9 +1,9 @@
|
||||
import { reactive, h } from 'vue'
|
||||
import { parseURL, parseQuery } from 'ufo'
|
||||
import { parseURL, parseQuery, withoutBase } from 'ufo'
|
||||
import { createError } from 'h3'
|
||||
import { defineNuxtPlugin } from '..'
|
||||
import { callWithNuxt } from '../nuxt'
|
||||
import { clearError, navigateTo, throwError } from '#app'
|
||||
import { clearError, navigateTo, throwError, useRuntimeConfig } from '#app'
|
||||
|
||||
interface Route {
|
||||
/** Percentage encoded pathname section of the URL. */
|
||||
@ -86,7 +86,9 @@ interface Router {
|
||||
}
|
||||
|
||||
export default defineNuxtPlugin<{ route: Route, router: Router }>((nuxtApp) => {
|
||||
const initialURL = process.client ? window.location.href : nuxtApp.ssrContext.url
|
||||
const initialURL = process.client
|
||||
? withoutBase(window.location.pathname, useRuntimeConfig().app.baseURL) + window.location.search + window.location.hash
|
||||
: nuxtApp.ssrContext.url
|
||||
const routes = []
|
||||
|
||||
const hooks: { [key in keyof RouterHooks]: RouterHooks[key][] } = {
|
||||
|
@ -54,7 +54,7 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
||||
nuxtApp.vueApp.component('NuxtNestedPage', NuxtPage)
|
||||
nuxtApp.vueApp.component('NuxtChild', NuxtPage)
|
||||
|
||||
const { baseURL } = useRuntimeConfig().app
|
||||
const baseURL = useRuntimeConfig().app.baseURL
|
||||
const routerHistory = process.client
|
||||
? createWebHistory(baseURL)
|
||||
: createMemoryHistory(baseURL)
|
||||
|
Loading…
Reference in New Issue
Block a user