fix(nuxt3): remove undefined headers in useRequestHeaders (#2526)

Co-authored-by: Pooya Parsa <pyapar@gmail.com>
This commit is contained in:
Vladyslav Poshvaniuk 2021-12-24 00:33:10 +02:00 committed by GitHub
parent 04b6466d37
commit 1e98259368
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,5 +7,5 @@ export function useRequestHeaders (include?) {
if (process.client) { return {} }
const headers: Record<string, string> = useNuxtApp().ssrContext?.req.headers ?? {}
if (!include) { return headers }
return Object.fromEntries(include.map(key => [key, headers[key]]))
return Object.fromEntries(include.filter(key => headers[key]).map(key => [key, headers[key]]))
}