You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// fetchApiServer is a wrapper around fetch that adds the necessary headers for the Crate API or the MCP API server.
28
+
/**
29
+
* Wrapper around fetch that adds the necessary headers for the Crate API or the MCP API server.
30
+
* Handles authentication, content type, and custom headers for backend routing.
31
+
* Redirects to login if the response is unauthorized (401).
32
+
*
33
+
* @param {string} path - The API endpoint path (appended to `/api/onboarding`).
34
+
* @param {ApiConfig} config - The API configuration, including authentication and MCP/Crate context.
35
+
* @param {string} [jq] - Optional jq transformation string for the proxy server.
36
+
* @param {string} [httpMethod='GET'] - The HTTP method to use (GET, POST, PATCH, etc.).
37
+
* @param {BodyInit} [body] - The request body, if applicable.
38
+
* @returns {Promise<Response>} The fetch Response object.
39
+
* @throws {APIError} Throws an APIError if the response is not ok.
40
+
*/
23
41
exportconstfetchApiServer=async(
24
42
path: string,
25
43
config: ApiConfig,
26
44
jq?: string,
27
45
httpMethod: string='GET',
28
46
body?: BodyInit,
29
47
): Promise<Response>=>{
30
-
// The default headers used for the fetch request.
31
-
// 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.
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.
// Set the jq header to do a jq transformation on the proxy server.
59
+
/**
60
+
* Set the jq header to do a jq transformation on the proxy server.
61
+
*/
40
62
if(jq)headers[jqHeader]=jq;
41
63
42
-
// 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,
43
-
// otherwise, the useCrateClusterHeader is set to true to indicate that the request is for the Crate
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.
0 commit comments