mirror of
https://github.com/harivansh-afk/asap.it.git
synced 2026-04-19 06:01:16 +00:00
first commit
This commit is contained in:
commit
1cdbffff09
200 changed files with 30007 additions and 0 deletions
14
app/lib/fetch.ts
Normal file
14
app/lib/fetch.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue