Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly bubble headers when throwing a data result #12845

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/proud-stingrays-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/router": patch
---

Properly bubble headers when throwing a `data()` result
20 changes: 15 additions & 5 deletions packages/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5052,15 +5052,25 @@ async function convertDataStrategyResultToDataResult(
type: ResultType.error,
error: result.data,
statusCode: result.init?.status,
headers: result.init?.headers
? new Headers(result.init.headers)
: undefined,
};
}

// Convert thrown data() to ErrorResponse instances
result = new ErrorResponseImpl(
result.init?.status || 500,
undefined,
result.data
);
return {
type: ResultType.error,
error: new ErrorResponseImpl(
result.init?.status || 500,
undefined,
result.data
),
statusCode: isRouteErrorResponse(result) ? result.status : undefined,
headers: result.init?.headers
? new Headers(result.init.headers)
: undefined,
};
}
return {
type: ResultType.error,
Expand Down
Loading