Skip to content

Commit 37296c8

Browse files
author
Andrey Fuchs
committed
Add pass credentails mode for WITH_CREDENTIALS is true in fetch
1 parent 3b6716a commit 37296c8

File tree

3 files changed

+5646
-5637
lines changed

3 files changed

+5646
-5637
lines changed

src/templates/core/OpenAPI.hbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import type { ApiRequestOptions } from './ApiRequestOptions';
44

55
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
66
type Headers = Record<string, string>;
7+
type CredentialModes = 'include' | 'omit' | 'same-origin'
78

89
type Config = {
910
BASE: string;
1011
VERSION: string;
1112
WITH_CREDENTIALS: boolean;
13+
CREDENTIALS: CredentialModes;
1214
TOKEN?: string | Resolver<string>;
1315
USERNAME?: string | Resolver<string>;
1416
PASSWORD?: string | Resolver<string>;
@@ -20,6 +22,7 @@ export const OpenAPI: Config = {
2022
BASE: '{{{server}}}',
2123
VERSION: '{{{version}}}',
2224
WITH_CREDENTIALS: false,
25+
CREDENTIALS: 'include',
2326
TOKEN: undefined,
2427
USERNAME: undefined,
2528
PASSWORD: undefined,

src/templates/core/fetch/sendRequest.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ async function sendRequest(
1616
};
1717

1818
if (OpenAPI.WITH_CREDENTIALS) {
19-
request.credentials = 'include';
19+
request.credentials = OpenAPI.CREDENTIALS;
2020
}
2121

2222
onCancel(() => controller.abort());

0 commit comments

Comments
 (0)