Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.
/frameworkPublic archive
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/nuxt/src/app/plugins/router.ts
Original file line numberDiff line numberDiff line change
@@ -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. */
Expand DownExpand Up@@ -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][] } = {
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/src/pages/runtime/router.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -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)
Expand Down