@vite-pwa/nuxt
~~/server/plugins/meta-base.ts
export default defineNitroPlugin((nitroApp) => { nitroApp.hooks.hook('render:html', (html, { event }) => { html.head.unshift(`<base href="https://foo.example.com/" />`) })})
nitro: { imports: { dirs: ['./shared/types', './shared/utils'], }, }, imports: { dirs: ['../shared/types/**', '../shared/utils/**'], },
./typess/common.d.ts
type FooBar = { foo: string, bar: number }
import { useFetch } from 'nuxt/app'import { ref } from 'vue'export const useFetchTime = () => { const start = ref<DOMHighResTimeStamp | undefined>() const time = ref<number | undefined>() const fetchOptions: Pick<NonNullable<Parameters<typeof useFetch>[1]>, 'onRequest' | 'onResponse'> = { onRequest({ request, options }) { start.value = performance.now() }, onResponse({ request, response, options }) { const now = performance.now() if (start.value) { time.value = start.value - now } }, } return { start, time, fetchOptions }}
export const useFetchTime => ...
onRequest
onResponse