🎉 first commit
This commit is contained in:
10
app/lib/fetch.ts
Normal file
10
app/lib/fetch.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
type CommonRequest = Omit<RequestInit, 'body'> & { body?: URLSearchParams | FormData | string };
|
||||
|
||||
export async function request(url: string, init?: CommonRequest) {
|
||||
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 });
|
||||
}
|
||||
Reference in New Issue
Block a user