mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
feat(composables): start new useResponseHeader and useResponseHeaders composables
This commit is contained in:
parent
76925a4477
commit
cff7f5987a
@ -24,7 +24,7 @@ export { useFetch, useLazyFetch } from './fetch'
|
||||
export type { FetchResult, UseFetchOptions } from './fetch'
|
||||
export { useCookie, refreshCookie } from './cookie'
|
||||
export type { CookieOptions, CookieRef } from './cookie'
|
||||
export { onPrehydrate, prerenderRoutes, useRequestHeaders, useRequestEvent, useRequestFetch, setResponseStatus } from './ssr'
|
||||
export { onPrehydrate, prerenderRoutes, useRequestHeaders, useRequestEvent, useRequestFetch, setResponseStatus, useResponseHeader, useResponseHeaders } from './ssr'
|
||||
export { onNuxtReady } from './ready'
|
||||
export { abortNavigation, addRouteMiddleware, defineNuxtRouteMiddleware, onBeforeRouteLeave, onBeforeRouteUpdate, setPageLayout, navigateTo, useRoute, useRouter } from './router'
|
||||
export type { AddRouteMiddlewareOptions, RouteMiddleware } from './router'
|
||||
|
@ -1,5 +1,5 @@
|
||||
import type { H3Event } from 'h3'
|
||||
import { setResponseStatus as _setResponseStatus, appendHeader, getRequestHeader, getRequestHeaders } from 'h3'
|
||||
import { setResponseStatus as _setResponseStatus, appendHeader, getRequestHeader, getRequestHeaders, setResponseHeader, setResponseHeaders } from 'h3'
|
||||
import { getCurrentInstance } from 'vue'
|
||||
import { useServerHead } from '@unhead/vue'
|
||||
|
||||
@ -61,6 +61,20 @@ export function setResponseStatus (arg1: H3Event | number | undefined, arg2?: nu
|
||||
}
|
||||
}
|
||||
|
||||
/** @since 3.11.3 */
|
||||
export function useResponseHeader (header: string, value: string) {
|
||||
if (import.meta.client) { return undefined }
|
||||
const event = useRequestEvent()
|
||||
return event ? setResponseHeader(event, header, value) : undefined
|
||||
}
|
||||
|
||||
/** @since 3.11.3 */
|
||||
export function useResponseHeaders (headers: Record<string, string>) {
|
||||
if (import.meta.client) { return undefined }
|
||||
const event = useRequestEvent()
|
||||
return event ? setResponseHeaders(event, headers) : undefined
|
||||
}
|
||||
|
||||
/** @since 3.8.0 */
|
||||
export function prerenderRoutes (path: string | string[]) {
|
||||
if (!import.meta.server || !import.meta.prerender) { return }
|
||||
|
Loading…
Reference in New Issue
Block a user