Skip to content

Commit

Permalink
Added validation settings
Browse files Browse the repository at this point in the history
  • Loading branch information
jsimck committed Oct 23, 2024
1 parent 2f30ad3 commit 7da7477
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/core/src/http/HttpAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface HttpAgentRequestOptions {
) => HttpAgentResponse<B>)[];
abortController?: AbortController;
keepSensitiveHeaders?: boolean;
validateCookies?: boolean;
}

/**
Expand Down
8 changes: 6 additions & 2 deletions packages/core/src/http/HttpAgentImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,9 @@ export class HttpAgentImpl extends HttpAgent {
if (composedOptions.fetchOptions?.credentials === 'include') {
// mock default browser behavior for server-side (sending cookie with a fetch request)
composedOptions.fetchOptions.headers.Cookie =
this._cookie.getCookiesStringForCookieHeader(url);
this._cookie.getCookiesStringForCookieHeader(
options.validateCookies ? url : undefined
);
}

return composedOptions;
Expand Down Expand Up @@ -503,7 +505,9 @@ export class HttpAgentImpl extends HttpAgent {
if (receivedCookies.length > 0) {
this._cookie.parseFromSetCookieHeader(
receivedCookies,
agentResponse.params.url
this._defaultRequestOptions.validateCookies
? agentResponse.params.url
: undefined
);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/create-ima-app/template/ts/app/config/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const initSettings: InitSettingsFunction = (ns, oc, config) => {
'Accept-Language': config.$Language,
},
},
validateCookies: true, // Validate cookies when parsing from Set-Cookie header and when sending cookies from the server.
cache: true, // if value exists in cache then returned it else make request to remote server.
},
cacheOptions: {
Expand Down

0 comments on commit 7da7477

Please sign in to comment.