mirror of
https://github.com/stackblitz/bolt.new
synced 2024-11-27 14:32:46 +00:00
15 lines
465 B
TypeScript
15 lines
465 B
TypeScript
type CommonRequest = Omit<RequestInit, 'body'> & { body?: URLSearchParams };
|
|
|
|
export async function request(url: string, init?: CommonRequest) {
|
|
if (import.meta.env.DEV) {
|
|
const nodeFetch = await import('node-fetch');
|
|
const https = await import('node:https');
|
|
|
|
const agent = url.startsWith('https') ? new https.Agent({ rejectUnauthorized: false }) : undefined;
|
|
|
|
return nodeFetch.default(url, { ...init, agent });
|
|
}
|
|
|
|
return fetch(url, init);
|
|
}
|