You can run multiple Workers in a single dev command by passing multiple config files to wrangler dev:
wrangler dev --config ./web/wrangler.jsonc --config ./api/wrangler.jsoncPreviously, if you ran the command above and then also ran wrangler dev for a different Worker, the Workers running in separate wrangler dev sessions could not communicate with each other. This prevented you from being able to use Service Bindings and Tail Workers in local development, when running separate wrangler dev sessions.
Now, the following works as expected:
# Terminal 1: Run your application that includes both Web and API workerswrangler dev --config ./web/wrangler.jsonc --config ./api/wrangler.jsonc
# Terminal 2: Run your auth worker separatelywrangler dev --config ./auth/wrangler.jsoncThese Workers can now communicate with each other across separate dev commands, regardless of your development setup.
export default { async fetch(request, env) { // This service binding call now works across dev commands const authorized = await env.AUTH.isAuthorized(request);
if (!authorized) { return new Response('Unauthorized', { status: 401 }); }
return new Response('Hello from API Worker!', { status: 200 }); },};Check out the Developing with multiple Workers guide to learn more about the different approaches and when to use each one.
Source: Cloudflare
Latest Posts
- Microsoft Defender for Office 365: Admins can block external users in Microsoft Teams from Defender Portal [MC1200058]
![Microsoft Defender for Office 365: Admins can block external users in Microsoft Teams from Defender Portal [MC1200058] 2 pexels mirrographer 1194036](data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==)
- Microsoft Purview: Role management update [MC1199765]
![Microsoft Purview: Role management update [MC1199765] 3 pexels googledeepmind 17483871](data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==)
- Outlook: New and improved People Hub on Web [MC1199768]
![Outlook: New and improved People Hub on Web [MC1199768] 4 pexels therato 3408744](data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==)
- Learning Activities now available in Microsoft 365 Education and Copilot [MC1199766]
![Learning Activities now available in Microsoft 365 Education and Copilot [MC1199766] 5 pexels noellegracephotos 906018](data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==)

![Microsoft Defender for Office 365: Admins can block external users in Microsoft Teams from Defender Portal [MC1200058] 2 pexels mirrographer 1194036](https://mwpro.co.uk/wp-content/uploads/2024/08/pexels-mirrographer-1194036-150x150.webp)
![Microsoft Purview: Role management update [MC1199765] 3 pexels googledeepmind 17483871](https://mwpro.co.uk/wp-content/uploads/2024/08/pexels-googledeepmind-17483871-150x150.webp)
![Outlook: New and improved People Hub on Web [MC1199768] 4 pexels therato 3408744](https://mwpro.co.uk/wp-content/uploads/2024/08/pexels-therato-3408744-150x150.webp)
![Learning Activities now available in Microsoft 365 Education and Copilot [MC1199766] 5 pexels noellegracephotos 906018](https://mwpro.co.uk/wp-content/uploads/2024/08/pexels-noellegracephotos-906018-150x150.webp)
