Skip to content

Commit edf169d

Browse files
authored
Fix metafiles in child directory (#8503)
1 parent c48dce6 commit edf169d

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

.changeset/mighty-lies-see.md

Lines changed: 5 additions & 0 deletions
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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4668,10 +4668,12 @@ addEventListener('fetch', event => {});`
46684668
});
46694669

46704670
it("should ignore assets that match patterns in an .assetsignore file in the root of the assets directory", async () => {
4671+
const redirectsContent = "/foo /bar";
4672+
const headersContent = "/some-path\nX-Header: Custom-Value";
46714673
const assets = [
46724674
{ filePath: ".assetsignore", content: "*.bak\nsub-dir" },
4673-
{ filePath: "_redirects", content: "/foo /bar" },
4674-
{ filePath: "_headers", content: "/some-path\nX-Header: Custom-Value" },
4675+
{ filePath: "_redirects", content: redirectsContent },
4676+
{ filePath: "_headers", content: headersContent },
46754677
{ filePath: "file-1.txt", content: "Content of file-1" },
46764678
{ filePath: "file-2.bak", content: "Content of file-2" },
46774679
{ filePath: "file-3.txt", content: "Content of file-3" },
@@ -4691,7 +4693,10 @@ addEventListener('fetch', event => {});`
46914693
mockUploadWorkerRequest({
46924694
expectedAssets: {
46934695
jwt: "<<aus-completion-token>>",
4694-
config: {},
4696+
config: {
4697+
_headers: headersContent,
4698+
_redirects: redirectsContent,
4699+
},
46954700
},
46964701
expectedType: "none",
46974702
});

packages/wrangler/src/assets.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,10 @@ export function getAssetsOptions(
426426
);
427427
}
428428

429-
const redirects = maybeGetFile(path.join(directory, REDIRECTS_FILENAME));
430-
const headers = maybeGetFile(path.join(directory, HEADERS_FILENAME));
429+
const redirects = maybeGetFile(
430+
path.join(resolvedAssetsPath, REDIRECTS_FILENAME)
431+
);
432+
const headers = maybeGetFile(path.join(resolvedAssetsPath, HEADERS_FILENAME));
431433

432434
// defaults are set in asset worker
433435
const assetConfig: AssetConfig = {

0 commit comments

Comments
 (0)