Skip to content

Commit 7352551

Browse files
committed
Merge branch 'main' into agents-sdk-module
# Conflicts: # src/client.ts
2 parents 8685041 + 0bf7682 commit 7352551

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

src/client.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export function createClient(config: {
3030
token?: string;
3131
serviceToken?: string;
3232
requiresAuth?: boolean;
33+
functionsVersion?: string;
3334
options?: CreateClientOptions;
3435
}) {
3536
const {
@@ -39,6 +40,7 @@ export function createClient(config: {
3940
serviceToken,
4041
requiresAuth = false,
4142
options,
43+
functionsVersion,
4244
} = config;
4345

4446
const socketConfig: RoomsSocketConfig = {
@@ -53,11 +55,20 @@ export function createClient(config: {
5355
config: socketConfig,
5456
});
5557

58+
const headers = {
59+
"X-App-Id": String(appId),
60+
};
61+
62+
const functionHeaders = functionsVersion
63+
? {
64+
...headers,
65+
"Base44-Functions-Version": functionsVersion,
66+
}
67+
: headers;
68+
5669
const axiosClient = createAxiosClient({
5770
baseURL: `${serverUrl}/api`,
58-
headers: {
59-
"X-App-Id": String(appId),
60-
},
71+
headers,
6172
token,
6273
requiresAuth,
6374
appId,
@@ -67,9 +78,7 @@ export function createClient(config: {
6778

6879
const functionsAxiosClient = createAxiosClient({
6980
baseURL: `${serverUrl}/api`,
70-
headers: {
71-
"X-App-Id": String(appId),
72-
},
81+
headers: functionHeaders,
7382
token,
7483
requiresAuth,
7584
appId,
@@ -80,9 +89,7 @@ export function createClient(config: {
8089

8190
const serviceRoleAxiosClient = createAxiosClient({
8291
baseURL: `${serverUrl}/api`,
83-
headers: {
84-
"X-App-Id": String(appId),
85-
},
92+
headers,
8693
token: serviceToken,
8794
serverUrl,
8895
appId,
@@ -91,9 +98,7 @@ export function createClient(config: {
9198

9299
const serviceRoleFunctionsAxiosClient = createAxiosClient({
93100
baseURL: `${serverUrl}/api`,
94-
headers: {
95-
"X-App-Id": String(appId),
96-
},
101+
headers: functionHeaders,
97102
token: serviceToken,
98103
serverUrl,
99104
appId,
@@ -206,6 +211,7 @@ export function createClientFromRequest(request: Request) {
206211
);
207212
const appId = request.headers.get("Base44-App-Id");
208213
const serverUrlHeader = request.headers.get("Base44-Api-Url");
214+
const functionsVersion = request.headers.get("Base44-Functions-Version");
209215

210216
if (!appId) {
211217
throw new Error(
@@ -248,5 +254,6 @@ export function createClientFromRequest(request: Request) {
248254
appId,
249255
token: userToken,
250256
serviceToken: serviceRoleToken,
257+
functionsVersion: functionsVersion ?? undefined,
251258
});
252259
}

0 commit comments

Comments
 (0)