Skip to content

Commit 23ee2de

Browse files
committed
fix #1550, add "X-Content-Raw" header
1 parent bfdd099 commit 23ee2de

File tree

3 files changed

+29
-22
lines changed

3 files changed

+29
-22
lines changed

.changeset/new-glasses-march.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/start": patch
3+
---
4+
5+
fix #1550, add "X-Content-Raw" header

packages/start/src/runtime/server-handler.ts

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
import { crossSerializeStream, fromJSON, getCrossReferenceHeader } from "seroval";
33
// @ts-ignore
44
import {
5-
CustomEventPlugin,
6-
DOMExceptionPlugin,
7-
EventPlugin,
8-
FormDataPlugin,
9-
HeadersPlugin,
10-
ReadableStreamPlugin,
11-
RequestPlugin,
12-
ResponsePlugin,
13-
URLPlugin,
14-
URLSearchParamsPlugin
5+
CustomEventPlugin,
6+
DOMExceptionPlugin,
7+
EventPlugin,
8+
FormDataPlugin,
9+
HeadersPlugin,
10+
ReadableStreamPlugin,
11+
RequestPlugin,
12+
ResponsePlugin,
13+
URLPlugin,
14+
URLSearchParamsPlugin
1515
} from "seroval-plugins/web";
1616
import { sharedConfig } from "solid-js";
1717
import { renderToString } from "solid-js/web";
@@ -167,15 +167,18 @@ async function handleServerFunction(h3Event: HTTPEvent) {
167167
}
168168

169169
// handle responses
170-
if (result instanceof Response && instance) {
171-
// forward headers
172-
if (result.headers) mergeResponseHeaders(h3Event, result.headers);
173-
// forward non-redirect statuses
174-
if (result.status && (result.status < 300 || result.status >= 400))
175-
setResponseStatus(h3Event, result.status);
176-
if ((result as any).customBody) {
177-
result = await (result as any).customBody();
178-
} else if (result.body == undefined) result = null;
170+
if (result instanceof Response) {
171+
if (result.headers && result.headers.has("X-Content-Raw")) return result;
172+
if (instance) {
173+
// forward headers
174+
if (result.headers) mergeResponseHeaders(h3Event, result.headers);
175+
// forward non-redirect statuses
176+
if (result.status && (result.status < 300 || result.status >= 400))
177+
setResponseStatus(h3Event, result.status);
178+
if ((result as any).customBody) {
179+
result = await (result as any).customBody();
180+
} else if (result.body == undefined) result = null;
181+
}
179182
}
180183

181184
// handle no JS success case

packages/start/src/shared/GET.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1+
// @refresh skip
12
/**
23
*
34
* Read more: https://docs.solidjs.com/solid-start/reference/server/get
45
*/
56
export function GET<T extends (...args: any[]) => any>(fn: T) {
6-
return (...args: Parameters<T>) => {
7-
return (fn as any).GET(...args) as ReturnType<T>;
8-
};
7+
return (fn as any).GET as (...args: Parameters<T>) => ReturnType<T>
98
}

0 commit comments

Comments
 (0)