|
1 | | -import middleware from "solid-start:middleware"; |
2 | 1 | import { defineHandler, getCookie, H3, type H3Event, redirect, setCookie } from "h3"; |
3 | 2 | import { join } from "pathe"; |
4 | 3 | import type { JSX } from "solid-js"; |
5 | 4 | import { sharedConfig } from "solid-js"; |
6 | 5 | import { getRequestEvent, renderToStream, renderToString } from "solid-js/web"; |
| 6 | +import middleware from "solid-start:middleware"; |
7 | 7 |
|
8 | 8 | import { createRoutes } from "../router.tsx"; |
9 | 9 | import { decorateHandler, decorateMiddleware } from "./fetchEvent.ts"; |
10 | 10 | import { getSsrManifest } from "./manifest/ssr-manifest.ts"; |
11 | 11 | import { matchAPIRoute } from "./routes.ts"; |
12 | 12 | import { handleServerFunction } from "./server-functions-handler.ts"; |
13 | 13 | import type { |
14 | | - APIEvent, |
15 | | - FetchEvent, |
16 | | - HandlerOptions, |
17 | | - PageEvent, |
| 14 | + APIEvent, |
| 15 | + FetchEvent, |
| 16 | + HandlerOptions, |
| 17 | + PageEvent, |
18 | 18 | } from "./types.ts"; |
19 | 19 | import { getExpectedRedirectStatus } from "./util.ts"; |
20 | 20 |
|
@@ -235,15 +235,32 @@ function produceResponseWithEventHeaders(res: Response) { |
235 | 235 |
|
236 | 236 | // Response.redirect returns an immutable value, so we clone on any redirect just in case |
237 | 237 | if(300 <= res.status && res.status < 400) { |
| 238 | + const cookies = res.headers.getSetCookie?.() ?? []; |
| 239 | + const headers = new Headers(); |
| 240 | + res.headers.forEach((value, key) => { |
| 241 | + if (key.toLowerCase() !== 'set-cookie') { |
| 242 | + headers.set(key, value); |
| 243 | + } |
| 244 | + }); |
| 245 | + for (const cookie of cookies) { |
| 246 | + headers.append('Set-Cookie', cookie); |
| 247 | + } |
238 | 248 | ret = new Response(res.body, { |
239 | 249 | status: res.status, |
240 | 250 | statusText: res.statusText, |
241 | | - headers: Object.fromEntries(res.headers.entries()) |
| 251 | + headers, |
242 | 252 | }); |
243 | 253 | } |
244 | 254 |
|
| 255 | + const eventCookies = event.response.headers.getSetCookie?.() ?? []; |
| 256 | + for (const cookie of eventCookies) { |
| 257 | + ret.headers.append('Set-Cookie', cookie); |
| 258 | + } |
| 259 | + |
245 | 260 | for(const [name, value] of event.response.headers) { |
246 | | - ret.headers.set(name, value); |
| 261 | + if (name.toLowerCase() !== 'set-cookie') { |
| 262 | + ret.headers.set(name, value); |
| 263 | + } |
247 | 264 | } |
248 | 265 |
|
249 | 266 | return ret |
|
0 commit comments