File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change 1
1
import type { FetchError , FetchOptions } from 'ofetch'
2
2
import { stringify } from 'qs'
3
- import dns from 'dns'
4
3
import type { Strapi4Error } from '../types/v4'
5
4
import type { Strapi3Error } from '../types/v3'
6
5
import { useStrapiUrl } from './useStrapiUrl'
@@ -9,8 +8,11 @@ import { useStrapiToken } from './useStrapiToken'
9
8
import { useNuxtApp } from '#imports'
10
9
11
10
// Fixes `ECONNREFUSED` on Node 18: https://github.com/node-fetch/node-fetch/issues/1624#issuecomment-1407717012
11
+ // Import dns only if running in a server environment during development
12
12
if ( process . server && process . dev ) {
13
- dns . setDefaultResultOrder ( 'ipv4first' )
13
+ import ( 'dns' )
14
+ . then ( ( dns ) => dns . setDefaultResultOrder ( 'ipv4first' ) )
15
+ . catch ( ( error ) => console . error ( 'Error importing dns module:' , error ) )
14
16
}
15
17
16
18
const defaultErrors = ( err : FetchError ) => ( {
You can’t perform that action at this time.
0 commit comments