From 93b8bb8d15bb59d54179c9e8bb0291955078212c Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Mon, 27 Nov 2023 14:52:37 +0100 Subject: [PATCH] fix(useStrapiClient): prevent cookie Fixes #366, fixes #364, fixes #138, fixes #229 --- src/runtime/composables/useStrapiClient.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/runtime/composables/useStrapiClient.ts b/src/runtime/composables/useStrapiClient.ts index 49f4aa87..7c5651ce 100644 --- a/src/runtime/composables/useStrapiClient.ts +++ b/src/runtime/composables/useStrapiClient.ts @@ -1,5 +1,6 @@ import type { FetchError, FetchOptions } from 'ofetch' import { stringify } from 'qs' +import dns from 'dns' import type { Strapi4Error } from '../types/v4' import type { Strapi3Error } from '../types/v3' import { useStrapiUrl } from './useStrapiUrl' @@ -7,6 +8,11 @@ import { useStrapiVersion } from './useStrapiVersion' import { useStrapiToken } from './useStrapiToken' import { useNuxtApp } from '#imports' +// Fixes `ECONNREFUSED` on Node 18: https://github.com/node-fetch/node-fetch/issues/1624#issuecomment-1407717012 +if (process.server && process.dev) { + dns.setDefaultResultOrder('ipv4first') +} + const defaultErrors = (err: FetchError) => ({ v4: { error: {