Skip to content

Commit bbd030c

Browse files
committed
feat: add Cloudflare-Workers-Script-Api-Date header
Wrangler differs from the Dash and other clients in that it makes a lot decisions for the user regarding the status of the Worker subdomain. The header should help with existing and future breaking changes between Wrangler and the API.
1 parent 3ebff7f commit bbd030c

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

packages/wrangler/src/__tests__/deploy.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6014,6 +6014,42 @@ addEventListener('fetch', event => {});`
60146014
vi.useRealTimers();
60156015
});
60166016

6017+
it("should include Cloudflare-Workers-Script-Api-Date header", async () => {
6018+
writeWranglerConfig();
6019+
writeWorkerSource();
6020+
mockUploadWorkerRequest();
6021+
mockGetWorkerSubdomain({ enabled: false });
6022+
mockSubDomainRequest();
6023+
msw.use(
6024+
http.post(
6025+
`*/accounts/:accountId/workers/scripts/:scriptName/subdomain`,
6026+
async ({ request, params }) => {
6027+
expect(params.accountId).toEqual("some-account-id");
6028+
expect(params.scriptName).toEqual("test-name");
6029+
expect(
6030+
request.headers.get("Cloudflare-Workers-Script-Api-Date")
6031+
).toEqual("2025-08-01");
6032+
return HttpResponse.json(
6033+
createFetchResult({ enabled: true, previews_enabled: false })
6034+
);
6035+
},
6036+
{ once: true }
6037+
)
6038+
);
6039+
6040+
await runWrangler("deploy ./index");
6041+
6042+
expect(std.out).toMatchInlineSnapshot(`
6043+
"Total Upload: xx KiB / gzip: xx KiB
6044+
Worker Startup Time: 100 ms
6045+
Uploaded test-name (TIMINGS)
6046+
Deployed test-name triggers (TIMINGS)
6047+
https://test-name.test-sub-domain.workers.dev
6048+
Current Version ID: Galaxy-Class"
6049+
`);
6050+
expect(std.err).toMatchInlineSnapshot(`""`);
6051+
});
6052+
60176053
it("should deploy to a workers.dev domain if workers_dev is undefined", async () => {
60186054
writeWranglerConfig();
60196055
writeWorkerSource();

packages/wrangler/src/triggers/deploy.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ async function subdomainDeploy(
362362
}),
363363
headers: {
364364
"Content-Type": "application/json",
365+
"Cloudflare-Workers-Script-Api-Date": "2025-08-01",
365366
},
366367
});
367368
}

0 commit comments

Comments
 (0)