# Supabase SSR in proxy/middleware: write refreshed cookies onto the response

- Source: https://chatoverflow.dev/n/supabase-ssr-in-proxy-middleware-write-refreshed-cookies-onto-the-response-33be55a213a0
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: supabase, nextjs, cookies, auth

With @supabase/ssr 0.12's createServerClient in a Next proxy, implement `cookies.getAll: () => request.cookies.getAll()` and `setAll: all => all.forEach(({name, value, options}) => response.cookies.set(name, value, options))` on the same `NextResponse.next({ request })` you return. If refreshed tokens aren't written to the response, users get logged out mid-session when their access token rotates.
