Skip to content

Commit 8e3e883

Browse files
author
Raphael Kabo
committed
Add comments, fix avatar API call
1 parent 77454b2 commit 8e3e883

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

server/idapiProxy.ts

+21
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,25 @@ const idapiOrOAuthHeaders = ({
100100
}
101101
};
102102

103+
/**
104+
* Prepares the options object for a fetch request to IDAPI
105+
* or Avatar API (AAPI).
106+
*
107+
* @param options - The options object to prepare
108+
* @param options.sendAuthHeader - Whether to send the access token or IDAPI cookies
109+
* in the request
110+
* @param options.useOkta - Whether to use Okta for authentication
111+
* @param options.path - The path to the IDAPI endpoint (e.g. '/user/me')
112+
* @param options.subdomain - The subdomain of the IDAPI endpoint
113+
* (e.g. 'idapi' or 'avatar')
114+
* @param options.method - The HTTP method to use
115+
* @param options.cookies - The cookies coming from the client. These are used to
116+
* build the security and cookie headers in the request
117+
* @param options.signedCookies - The signed cookies coming from the client, also
118+
* used to build the security and cookie headers in the request
119+
* @param options.config - The IDAPI configuration object
120+
* @returns The options object for the fetch request
121+
*/
103122
export const setOptions = ({
104123
sendAuthHeader,
105124
useOkta,
@@ -170,6 +189,8 @@ export const idapiFetch = async <T>({
170189
* @param url The IDAPI endpoint to hit
171190
* @param method The HTTP method to use (default: 'GET')
172191
* @param processData A function to process the JSON response (optional)
192+
* @param sendAuthHeader Whether to send the access token or IDAPI cookies
193+
* in the request (default: false)
173194
* @returns An Express route handler
174195
*/
175196
export const idapiProxyHandler =

server/routes/aapi.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ router.get(
4141
}
4242
const { useOkta } = await getOktaConfig();
4343
const options = setOptions({
44-
sendAuthHeader: false,
44+
sendAuthHeader: true,
4545
useOkta,
4646
path: '/v1/avatars/user/me/active',
4747
subdomain: 'avatar',

0 commit comments

Comments
 (0)