From 3d42d7571fd596e57205e283e028552a98a9eec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Re=C3=A9?= Date: Mon, 6 Jul 2026 21:38:14 +0200 Subject: [PATCH] NextServer.NextResponse: add redirect and the response cookie store MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The static redirect constructor (307 default, ~status for permanent variants) alongside json/next, and the response cookies (Set-Cookie store, distinct from NextRequest's request store) as a @get — the shared Cookies surface fits both. Extracted from njc-2026 (sc-50), where the proxy uses them for the language-cookie protocol. --- src/NextServer.res | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/NextServer.res b/src/NextServer.res index b86e0b8..45e000e 100644 --- a/src/NextServer.res +++ b/src/NextServer.res @@ -67,6 +67,17 @@ module NextResponse = { } @module("next/server") @scope("NextResponse") external next: nextOptions => t = "next" + + /* Redirect to an absolute URL (build it from the request's nextUrl.origin). + * Defaults to 307; pass ~status for 301/302/308. */ + @module("next/server") @scope("NextResponse") + external redirect: (string, ~status: int=?) => t = "redirect" + + /* The RESPONSE cookie store (Set-Cookie): what a middleware/route handler + * sets on the way out — distinct from the request store on NextRequest.t. + * The shared Cookies surface (get/set/delete/…) fits both. */ + @get + external cookies: t => GreenfinityNext.Cookies.t = "cookies" } module Middleware = {