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

Cast redirectBack return value to TypedResponse<never> #303

Merged
merged 1 commit into from
Feb 23, 2024
Merged
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
6 changes: 4 additions & 2 deletions src/server/redirect-back.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { TypedResponse } from "@remix-run/node";

/**
* Create a new Response with a redirect set to the URL the user was before.
* It uses the Referer header to detect the previous URL. It asks for a fallback
Expand All @@ -15,7 +17,7 @@
export function redirectBack(
request: Request,
{ fallback, ...init }: ResponseInit & { fallback: string },
): Response {
): TypedResponse<never> {
let responseInit = init;
if (typeof responseInit === "number") {
responseInit = { status: responseInit };
Expand All @@ -29,5 +31,5 @@ export function redirectBack(
return new Response(null, {
...responseInit,
headers,
});
}) as TypedResponse<never>;
}