Skip to content

Commit

Permalink
fix(defer): respect headers and status
Browse files Browse the repository at this point in the history
  • Loading branch information
manzano78 committed Feb 10, 2023
1 parent 918b158 commit 5cfcc9a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/nasty-carrots-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/router": minor
---

Remix document response now respects headers and status code set in defer()
4 changes: 4 additions & 0 deletions packages/router/__tests__/router-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12350,6 +12350,10 @@ describe("a router", () => {
"x-custom": "yes",
}),
},
statusCode: 201,
loaderHeaders: {
deferred: new Headers({ "x-custom": "yes" }),
}
});
});

Expand Down
7 changes: 6 additions & 1 deletion packages/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3183,7 +3183,12 @@ async function callLoaderOrAction(
}

if (result instanceof DeferredData) {
return { type: ResultType.deferred, deferredData: result };
return {
type: ResultType.deferred,
deferredData: result,
statusCode: result.init?.status,
headers: result.init?.headers && new Headers(result.init.headers),
};
}

return { type: ResultType.data, data: result };
Expand Down

0 comments on commit 5cfcc9a

Please sign in to comment.