[skip ci] send cookie to other origins only if account is enabled

This commit is contained in:
tom
2023-08-08 08:31:36 -04:00
parent 039f1f113c
commit 550eecb86f
+6 -1
View File
@@ -4,6 +4,7 @@ import React from 'react';
import type { CsrfData } from 'types/client/account';
import appConfig from 'configs/app/config';
import isBodyAllowed from 'lib/api/isBodyAllowed';
import isNeedProxy from 'lib/api/isNeedProxy';
import { getResourceKey } from 'lib/api/useApiQuery';
@@ -44,7 +45,11 @@ export default function useApiFetch() {
return fetch<SuccessType, ErrorType>(
url,
{
credentials: 'include',
// as of today, we use cookies only
// for user authentication in My account
// for API rate-limits (cannot use in the condition though, but we agreed with devops team that should not be an issue)
// change condition here if something is changed
credentials: appConfig.account.isEnabled ? 'include' : 'same-origin',
headers,
...fetchParams,
},