Skip to content

Commit 5cfcc9a

Browse files
fix(defer): respect headers and status
1 parent 918b158 commit 5cfcc9a

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@remix-run/router": minor
3+
---
4+
5+
Remix document response now respects headers and status code set in defer()

packages/router/__tests__/router-test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12350,6 +12350,10 @@ describe("a router", () => {
1235012350
"x-custom": "yes",
1235112351
}),
1235212352
},
12353+
statusCode: 201,
12354+
loaderHeaders: {
12355+
deferred: new Headers({ "x-custom": "yes" }),
12356+
}
1235312357
});
1235412358
});
1235512359

packages/router/router.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3183,7 +3183,12 @@ async function callLoaderOrAction(
31833183
}
31843184

31853185
if (result instanceof DeferredData) {
3186-
return { type: ResultType.deferred, deferredData: result };
3186+
return {
3187+
type: ResultType.deferred,
3188+
deferredData: result,
3189+
statusCode: result.init?.status,
3190+
headers: result.init?.headers && new Headers(result.init.headers),
3191+
};
31873192
}
31883193

31893194
return { type: ResultType.data, data: result };

0 commit comments

Comments
 (0)