aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-03-15 09:55:01 -0300
committerSebastian <sebasjm@gmail.com>2023-03-15 09:55:01 -0300
commitf414ca39e446563eb10c3c20defe79952fe71e6a (patch)
tree7d3307f010ca0bd2e42031c6e3780437aa27e1ce
parentae4d4647e988a6eb8e9fd87af3385371ba56ab43 (diff)
prevent cors and cache options
-rw-r--r--packages/web-util/src/utils/request.ts7
1 files changed, 6 insertions, 1 deletions
diff --git a/packages/web-util/src/utils/request.ts b/packages/web-util/src/utils/request.ts
index c7bca2de9..d05a4ec84 100644
--- a/packages/web-util/src/utils/request.ts
+++ b/packages/web-util/src/utils/request.ts
@@ -51,6 +51,8 @@ export async function defaultRequestHandler<T>(
const requestBody = options?.data;
const requestTimeout = options?.timeout ?? 5 * 1000;
const requestParams = options.params ?? {};
+ const requestPreventCache = options.preventCache ?? false;
+ const requestPreventCors = options.preventCors ?? false;
const _url = new URL(`${baseUrl}${endpoint}`);
@@ -84,7 +86,8 @@ export async function defaultRequestHandler<T>(
headers: requestHeaders,
method: requestMethod,
credentials: "omit",
- mode: "cors",
+ mode: requestPreventCors ? "no-cors" : "cors",
+ cache: requestPreventCache ? "no-cache" : "default",
body: payload,
signal: controller.signal,
});
@@ -301,6 +304,8 @@ export interface RequestOptions {
username: string;
password: string;
};
+ preventCache?: boolean;
+ preventCors?: boolean;
data?: any;
params?: unknown;
timeout?: number;