Skip to content

Commit 0192aae

Browse files

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed
 

‎.changeset/mighty-lies-see.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
Fix Workers Assets metafiles (`_headers` and `_redirects`) resolution when running Wrangler from a different directory

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

+8-3
Original file line numberDiff line numberDiff line change
@@ -5227,10 +5227,12 @@ addEventListener('fetch', event => {});`
52275227
});
52285228

52295229
it("should ignore assets that match patterns in an .assetsignore file in the root of the assets directory", async () => {
5230+
const redirectsContent = "/foo /bar";
5231+
const headersContent = "/some-path\nX-Header: Custom-Value";
52305232
const assets = [
52315233
{ filePath: ".assetsignore", content: "*.bak\nsub-dir" },
5232-
{ filePath: "_redirects", content: "/foo /bar" },
5233-
{ filePath: "_headers", content: "/some-path\nX-Header: Custom-Value" },
5234+
{ filePath: "_redirects", content: redirectsContent },
5235+
{ filePath: "_headers", content: headersContent },
52345236
{ filePath: "file-1.txt", content: "Content of file-1" },
52355237
{ filePath: "file-2.bak", content: "Content of file-2" },
52365238
{ filePath: "file-3.txt", content: "Content of file-3" },
@@ -5250,7 +5252,10 @@ addEventListener('fetch', event => {});`
52505252
mockUploadWorkerRequest({
52515253
expectedAssets: {
52525254
jwt: "<<aus-completion-token>>",
5253-
config: {},
5255+
config: {
5256+
_headers: headersContent,
5257+
_redirects: redirectsContent,
5258+
},
52545259
},
52555260
expectedType: "none",
52565261
});

‎packages/wrangler/src/assets.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,10 @@ export function getAssetsOptions(
446446
}
447447
}
448448

449-
const redirects = maybeGetFile(path.join(directory, REDIRECTS_FILENAME));
450-
const headers = maybeGetFile(path.join(directory, HEADERS_FILENAME));
449+
const redirects = maybeGetFile(
450+
path.join(resolvedAssetsPath, REDIRECTS_FILENAME)
451+
);
452+
const headers = maybeGetFile(path.join(resolvedAssetsPath, HEADERS_FILENAME));
451453

452454
// defaults are set in asset worker
453455
const assetConfig: AssetConfig = {

0 commit comments

Comments
 (0)
Please sign in to comment.