Skip to content

Commit 3be6583

Browse files
dario-piotrowiczthomasgauvin
authored andcommitted
Add auth information to maybeStartOrUpdateRemoteProxySession and also fix the example's code formatting (#24206)
* include `auth` parameter in `maybeStartOrUpdateProxySession` docs * fix formatting of `maybeStartOrUpdateRempteProxySession` example
1 parent 3d2a819 commit 3be6583

File tree

1 file changed

+30
-34
lines changed
  • src/content/docs/workers/development-testing

1 file changed

+30
-34
lines changed

src/content/docs/workers/development-testing/index.mdx

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ This wrapper simplifies proxy session management. It takes:
366366

367367
- The path to your Wrangler config, or an object with remote bindings.
368368
- The current proxy session details (this parameter can be set to `null` or not being provided if none).
369+
- Potentially the auth data to use for the remote proxy session.
369370

370371
It returns an object with the proxy session details if started or updated, or `null` if no proxy session is needed.
371372

@@ -388,42 +389,37 @@ import { experimental_maybeStartOrUpdateRemoteProxySession } from "wrangler";
388389

389390
let mf: Miniflare | null;
390391

391-
let remoteProxySessionDetails: Awaited<
392-
ReturnType<typeof experimental_maybeStartOrUpdateRemoteProxySession>
393-
394-
> | null = null;
392+
let remoteProxySessionDetails: Awaited<ReturnType<typeof experimental_maybeStartOrUpdateRemoteProxySession>> | null = null;
395393

396394
async function startOrUpdateDevSession() {
397-
remoteProxySessionDetails =
398-
await experimental_maybeStartOrUpdateRemoteProxySession(
399-
{
400-
bindings: {
401-
MY_KV: {
402-
type: 'kv_namespace',
403-
id: 'kv-id',
404-
experimental_remote: true,
405-
}
406-
}
407-
},
408-
remoteProxySessionDetails
409-
);
410-
411-
const miniflareOptions: MiniflareOptions = {
412-
scriptPath: "./worker.js",
413-
kvNamespaces: {
414-
MY_KV: {
415-
id: "kv-id",
416-
remoteProxyConnectionString:
417-
remoteProxySessionDetails?.session.remoteProxyConnectionString,
418-
},
419-
},
420-
};
421-
422-
if (!mf) {
423-
mf = new Miniflare(miniflareOptions);
424-
} else {
425-
mf.setOptions(miniflareOptions);
426-
}
395+
remoteProxySessionDetails = await experimental_maybeStartOrUpdateRemoteProxySession({
396+
bindings: {
397+
MY_KV: {
398+
type: 'kv_namespace',
399+
id: 'kv-id',
400+
experimental_remote: true,
401+
}
402+
}
403+
},
404+
remoteProxySessionDetails
405+
);
406+
407+
const miniflareOptions: MiniflareOptions = {
408+
scriptPath: "./worker.js",
409+
kvNamespaces: {
410+
MY_KV: {
411+
id: "kv-id",
412+
remoteProxyConnectionString:
413+
remoteProxySessionDetails?.session.remoteProxyConnectionString,
414+
},
415+
},
416+
};
417+
418+
if (!mf) {
419+
mf = new Miniflare(miniflareOptions);
420+
} else {
421+
mf.setOptions(miniflareOptions);
422+
}
427423
}
428424

429425
// ... tool logic that invokes `startOrUpdateDevSession()` ...

0 commit comments

Comments
 (0)