2023-05-06 22:00:50 +00:00
|
|
|
// @ts-check
|
2022-09-15 11:01:52 +00:00
|
|
|
import { Agent as HTTPSAgent } from 'node:https'
|
2022-11-15 14:33:43 +00:00
|
|
|
import { $fetch } from 'ofetch'
|
2022-09-15 11:01:52 +00:00
|
|
|
|
|
|
|
export const viteNodeOptions = JSON.parse(process.env.NUXT_VITE_NODE_OPTIONS || '{}')
|
|
|
|
|
|
|
|
export const viteNodeFetch = $fetch.create({
|
|
|
|
baseURL: viteNodeOptions.baseURL,
|
2023-05-06 22:00:50 +00:00
|
|
|
// @ts-expect-error https://github.com/node-fetch/node-fetch#custom-agent
|
2022-09-15 11:01:52 +00:00
|
|
|
agent: viteNodeOptions.baseURL.startsWith('https://')
|
|
|
|
? new HTTPSAgent({ rejectUnauthorized: false })
|
|
|
|
: null
|
|
|
|
})
|