/* eslint-disable no-redeclare */ import type { CompatibilityEvent } from 'h3' import { useNuxtApp } from '#app' import { NuxtApp } from '#app/nuxt' export function useRequestHeaders (include: K[]): Record export function useRequestHeaders (): Readonly> export function useRequestHeaders (include?) { if (process.client) { return {} } const headers: Record = useNuxtApp().ssrContext?.event.req.headers ?? {} if (!include) { return headers } return Object.fromEntries(include.filter(key => headers[key]).map(key => [key, headers[key]])) } export function useRequestEvent (nuxtApp: NuxtApp = useNuxtApp()): CompatibilityEvent { return nuxtApp.ssrContext?.event as CompatibilityEvent }