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
|
|
|
|
2023-06-28 21:19:51 +00:00
|
|
|
/** @type {import('../vite-node').ViteNodeServerOptions} */
|
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 })
|
2024-04-05 18:08:32 +00:00
|
|
|
: null,
|
2022-09-15 11:01:52 +00:00
|
|
|
})
|