redirectDocument
このコンテンツはまだ日本語訳がありません。
这是 redirect 的一个小包装器,它将触发文档级重定向到新位置,而不是客户端导航。
当您在同一个域中有一个 Remix 应用程序与一个非 Remix 应用程序相邻,并且需要从 Remix 应用程序重定向到非 Remix 应用程序时,此功能非常有用:
import { redirectDocument } from "@remix-run/node"; // or cloudflare/deno
export const action = async () => {  const userSession = await getUserSessionOrWhatever();
  if (!userSession) {    // Assuming `/login` is a separate non-Remix app    return redirectDocument("/login");  }
  return json({ ok: true });};就像 redirect 一样,它接受状态代码或 ResponseInit 作为第二个参数:
redirectDocument(path, 301);redirectDocument(path, 303);redirectDocument(path, {  headers: {    "Set-Cookie": await commitSession(session),  },});