Skip to content

Commit

Permalink
fix #1550, add "X-Content-Raw" header
Browse files Browse the repository at this point in the history
  • Loading branch information
ryansolid committed Jun 18, 2024
1 parent bfdd099 commit 23ee2de
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 22 deletions.
5 changes: 5 additions & 0 deletions .changeset/new-glasses-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@solidjs/start": patch
---

fix #1550, add "X-Content-Raw" header
41 changes: 22 additions & 19 deletions packages/start/src/runtime/server-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
import { crossSerializeStream, fromJSON, getCrossReferenceHeader } from "seroval";
// @ts-ignore
import {
CustomEventPlugin,
DOMExceptionPlugin,
EventPlugin,
FormDataPlugin,
HeadersPlugin,
ReadableStreamPlugin,
RequestPlugin,
ResponsePlugin,
URLPlugin,
URLSearchParamsPlugin
CustomEventPlugin,
DOMExceptionPlugin,
EventPlugin,
FormDataPlugin,
HeadersPlugin,
ReadableStreamPlugin,
RequestPlugin,
ResponsePlugin,
URLPlugin,
URLSearchParamsPlugin
} from "seroval-plugins/web";
import { sharedConfig } from "solid-js";
import { renderToString } from "solid-js/web";
Expand Down Expand Up @@ -167,15 +167,18 @@ async function handleServerFunction(h3Event: HTTPEvent) {
}

// handle responses
if (result instanceof Response && instance) {
// forward headers
if (result.headers) mergeResponseHeaders(h3Event, result.headers);
// forward non-redirect statuses
if (result.status && (result.status < 300 || result.status >= 400))
setResponseStatus(h3Event, result.status);
if ((result as any).customBody) {
result = await (result as any).customBody();
} else if (result.body == undefined) result = null;
if (result instanceof Response) {
if (result.headers && result.headers.has("X-Content-Raw")) return result;
if (instance) {
// forward headers
if (result.headers) mergeResponseHeaders(h3Event, result.headers);
// forward non-redirect statuses
if (result.status && (result.status < 300 || result.status >= 400))
setResponseStatus(h3Event, result.status);
if ((result as any).customBody) {
result = await (result as any).customBody();
} else if (result.body == undefined) result = null;
}
}

// handle no JS success case
Expand Down
5 changes: 2 additions & 3 deletions packages/start/src/shared/GET.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// @refresh skip
/**
*
* Read more: https://docs.solidjs.com/solid-start/reference/server/get
*/
export function GET<T extends (...args: any[]) => any>(fn: T) {
return (...args: Parameters<T>) => {
return (fn as any).GET(...args) as ReturnType<T>;
};
return (fn as any).GET as (...args: Parameters<T>) => ReturnType<T>
}

0 comments on commit 23ee2de

Please sign in to comment.