diff --git a/site/src/middleware/fetch.global.ts b/site/src/middleware/fetch.global.ts index bfe4c5a87..983f3dd7b 100644 --- a/site/src/middleware/fetch.global.ts +++ b/site/src/middleware/fetch.global.ts @@ -1,8 +1,19 @@ export default defineNuxtRouteMiddleware(async () => { - const configStore = useConfigStore() - const userStore = useUserStore() - await Promise.all([ - configStore.fetchConfig(), - userStore.fetchCurrent(), - ]) + + const load = async () => { + const configStore = useConfigStore() + const userStore = useUserStore() + await Promise.all([ + configStore.fetchConfig(), + userStore.fetchCurrent(), + ]) + } + + const nuxtApp = useNuxtApp() + + // 服务端渲染,或者客服端渲染 + if (process.server || (process.client && !nuxtApp.isHydrating)) { + await load() + } + }) diff --git a/site/src/server/middleware/index.ts b/site/src/server/middleware/index.ts new file mode 100644 index 000000000..644292900 --- /dev/null +++ b/site/src/server/middleware/index.ts @@ -0,0 +1,3 @@ +export default defineEventHandler(async (event) => { + console.log('New request: ' + getRequestURL(event)) +})