Skip to content

Commit 3d06d36

Browse files
committed
Try hack
1 parent b7d9448 commit 3d06d36

File tree

1 file changed

+10
-5
lines changed
  • packages/gitbook-v2/src/lib/data

1 file changed

+10
-5
lines changed

packages/gitbook-v2/src/lib/data/api.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -579,12 +579,17 @@ export async function apiClient(input: DataFetcherInput = { apiToken: null }) {
579579
let serviceBinding: GitBookAPIServiceBinding | undefined;
580580

581581
try {
582-
const { env } = getCloudflareContext();
582+
const { env } = await getCloudflareContext({ async: true });
583583
serviceBinding = env.GITBOOK_API;
584-
} catch (error) {
585-
// IGNORE
586-
if (process.env.NODE_ENV !== 'development') {
587-
console.warn('Failed to get service binding', error);
584+
} catch {
585+
try {
586+
const { env } = getCloudflareContext();
587+
serviceBinding = env.GITBOOK_API;
588+
} catch (error) {
589+
// IGNORE
590+
if (process.env.NODE_ENV !== 'development') {
591+
console.warn('Failed to get service binding', error);
592+
}
588593
}
589594
}
590595

0 commit comments

Comments
 (0)