fix(nuxt): early return from refreshCookie on server

This commit is contained in:
Daniel Roe 2024-03-21 14:32:02 +00:00
parent cca81bcae4
commit 22ada37b4f
No known key found for this signature in database
GPG Key ID: 3714AB03996F442B

View File

@ -132,7 +132,7 @@ export function useCookie<T = string | null | undefined> (name: string, _opts?:
}
/** @since 3.10.0 */
export function refreshCookie (name: string) {
if (store || typeof BroadcastChannel === 'undefined') { return }
if (import.meta.server || store || typeof BroadcastChannel === 'undefined') { return }
new BroadcastChannel(`nuxt:cookies:${name}`)?.postMessage({ refresh: true })
}