Skip to content

Commit be1ba48

Browse files
committed
Update fetch.ts
1 parent ae96dcd commit be1ba48

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/lib/api/fetch.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,20 @@ export const fetchApiServer = async (
4545
httpMethod: string = 'GET',
4646
body?: BodyInit,
4747
): Promise<Response> => {
48-
/**
49-
* The default headers used for the fetch request.
50-
* The Authorization header is required for both the Crate API and the MCP API and the correct token is passed in the config object that is consumed outside this function from the context that has handled the OIDC flow to get a token.
51-
*/
48+
// The default headers used for the fetch request.
49+
// The Authorization header is required for both the Crate API and the MCP API and the correct token is passed in the config object that is consumed outside this function from the context that has handled the OIDC flow to get a token.
5250
const headers: { [key: string]: string } = {};
5351
if (httpMethod !== 'PATCH') {
5452
headers[contentTypeHeader] = 'application/json';
5553
} else {
5654
headers[contentTypeHeader] = 'application/merge-patch+json';
5755
}
5856

59-
/**
60-
* Set the jq header to do a jq transformation on the proxy server.
61-
*/
57+
// Set the jq header to do a jq transformation on the proxy server.
6258
if (jq) headers[jqHeader] = jq;
6359

64-
/**
65-
* If the config object has a mcpConfig, it is assumed that the request is for the MCP API server and the necessary headers are set for the backend to get the OIDC kubeconfig without exposing it to the frontend,
66-
* otherwise, the useCrateClusterHeader is set to true to indicate that the request is for the Crate.
67-
*/
60+
// If the config object has a mcpConfig, it is assumed that the request is for the MCP API server and the necessary headers are set for the backend to get the OIDC kubeconfig without exposing it to the frontend,
61+
// otherwise, the useCrateClusterHeader is set to true to indicate that the request is for the Crate.
6862
if (config.mcpConfig !== undefined) {
6963
headers[projectNameHeader] = config.mcpConfig.projectName;
7064
headers[workspaceNameHeader] = config.mcpConfig.workspaceName;
@@ -81,9 +75,7 @@ export const fetchApiServer = async (
8175

8276
if (!res.ok) {
8377
if (res.status === 401) {
84-
/**
85-
* Unauthorized (token expired), redirect to the login page.
86-
*/
78+
// Unauthorized (token expired), redirect to the login page.
8779
sessionStorage.setItem(AUTH_FLOW_SESSION_KEY, 'onboarding');
8880
window.location.replace(`/api/auth/onboarding/login?redirectTo=${encodeURIComponent(getRedirectSuffix())}`);
8981
}

0 commit comments

Comments
 (0)