From 0d9dfe0d94ee6eef9d2dbbe7d935beb00d5aafa8 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Mon, 30 May 2022 14:00:41 +0530 Subject: [PATCH] fix: `router.path` not consistent across envs (#446) (#684) fix #446 --- src/client/app/router.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/app/router.ts b/src/client/app/router.ts index 678cf754..2eca5b7b 100644 --- a/src/client/app/router.ts +++ b/src/client/app/router.ts @@ -1,7 +1,7 @@ import { reactive, inject, markRaw, nextTick, readonly } from 'vue' import type { Component, InjectionKey } from 'vue' import { PageData } from '../shared' -import { inBrowser } from './utils' +import { inBrowser, withBase } from './utils' import { siteDataRef } from './data' export interface Route { @@ -82,7 +82,7 @@ export function createRouter( throw new Error(`Invalid route component: ${comp}`) } - route.path = pendingPath + route.path = inBrowser ? pendingPath : withBase(pendingPath) route.component = markRaw(comp) route.data = import.meta.env.PROD ? markRaw(JSON.parse(__pageData)) @@ -127,7 +127,7 @@ export function createRouter( if (latestPendingPath === pendingPath) { latestPendingPath = null - route.path = pendingPath + route.path = inBrowser ? pendingPath : withBase(pendingPath) route.component = fallbackComponent ? markRaw(fallbackComponent) : null route.data = notFoundPageData }