@solidjs/start 0.5.8 → 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.
@@ -105,7 +105,7 @@ async function handleServerFunction(h3Event: H3Event) {
105
105
  );
106
106
  // what should work when #1721 is fixed
107
107
  // parsed.push(await request.formData);
108
- } else {
108
+ } else if (contentType?.startsWith("application/json")) {
109
109
  // workaround for https://github.com/unjs/nitro/issues/1721
110
110
  // (issue only in edge runtimes)
111
111
  const tmpReq = new Request(request, { ...request, body: (h3Event.node.req as any).body });
@@ -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
- const refererUrl = new URL(request.headers.get("referer")!);
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: refererUrl.toString(),
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 (x.status === 302 && !instance) setResponseStatus(h3Event, 302);
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.8",
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
- "./middleware": [
33
+ "middleware": [
34
34
  "./middleware/index.ts"
35
35
  ],
36
- "./server": [
36
+ "server": [
37
37
  "./server/index.tsx"
38
38
  ],
39
- "./client": [
39
+ "client": [
40
40
  "./client/index.tsx"
41
41
  ]
42
42
  }