@solidjs/start 0.5.9 → 0.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/server-handler.ts +19 -6
- package/package.json +4 -4
package/config/server-handler.ts
CHANGED
|
@@ -150,11 +150,17 @@ async function handleServerFunction(h3Event: H3Event) {
|
|
|
150
150
|
// handle no JS success case
|
|
151
151
|
if (!instance) {
|
|
152
152
|
const isError = result instanceof Error;
|
|
153
|
-
|
|
153
|
+
let redirectUrl = new URL(request.headers.get("referer")!).toString();
|
|
154
|
+
if (result instanceof Response && result.headers.has("Location")) {
|
|
155
|
+
redirectUrl = new URL(
|
|
156
|
+
result.headers.get("Location")!,
|
|
157
|
+
new URL(request.url).origin + import.meta.env.SERVER_BASE_URL
|
|
158
|
+
).toString();
|
|
159
|
+
}
|
|
154
160
|
return new Response(null, {
|
|
155
161
|
status: 302,
|
|
156
162
|
headers: {
|
|
157
|
-
Location:
|
|
163
|
+
Location: redirectUrl,
|
|
158
164
|
...(result
|
|
159
165
|
? {
|
|
160
166
|
"Set-Cookie": `flash=${JSON.stringify({
|
|
@@ -172,18 +178,25 @@ async function handleServerFunction(h3Event: H3Event) {
|
|
|
172
178
|
return serializeToStream(instance, result);
|
|
173
179
|
} catch (x) {
|
|
174
180
|
if (x instanceof Response) {
|
|
175
|
-
if (
|
|
181
|
+
if (singleFlight && instance) {
|
|
182
|
+
x = await handleSingleFlight(event, x);
|
|
183
|
+
}
|
|
184
|
+
if ((x as any).status === 302 && !instance) setResponseStatus(h3Event, 302);
|
|
176
185
|
// forward headers
|
|
177
|
-
if (x.headers) mergeResponseHeaders(h3Event, x.headers);
|
|
186
|
+
if ((x as any).headers) mergeResponseHeaders(h3Event, (x as any).headers);
|
|
178
187
|
if ((x as any).customBody) {
|
|
179
188
|
x = (x as any).customBody();
|
|
180
|
-
} else if (x.body == undefined) x = null;
|
|
189
|
+
} else if ((x as any).body == undefined) x = null;
|
|
190
|
+
if (instance) {
|
|
191
|
+
setHeader(h3Event, "content-type", "text/javascript");
|
|
192
|
+
return serializeToStream(instance, x);
|
|
193
|
+
}
|
|
181
194
|
}
|
|
182
195
|
return x;
|
|
183
196
|
}
|
|
184
197
|
}
|
|
185
198
|
|
|
186
|
-
async function handleSingleFlight(sourceEvent: FetchEvent, result: any) {
|
|
199
|
+
async function handleSingleFlight(sourceEvent: FetchEvent, result: any): Promise<Response> {
|
|
187
200
|
let revalidate: string[];
|
|
188
201
|
let url = new URL(sourceEvent.request.headers.get("referer")!).toString();
|
|
189
202
|
if (result instanceof Response) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidjs/start",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"publishConfig": {
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
".": [
|
|
31
31
|
"./shared/index.tsx"
|
|
32
32
|
],
|
|
33
|
-
"
|
|
33
|
+
"middleware": [
|
|
34
34
|
"./middleware/index.ts"
|
|
35
35
|
],
|
|
36
|
-
"
|
|
36
|
+
"server": [
|
|
37
37
|
"./server/index.tsx"
|
|
38
38
|
],
|
|
39
|
-
"
|
|
39
|
+
"client": [
|
|
40
40
|
"./client/index.tsx"
|
|
41
41
|
]
|
|
42
42
|
}
|