@opentf/afw-build 0.2.0 → 0.3.0
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/package.json +1 -1
- package/server.js +10 -4
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -153,10 +153,16 @@ export async function serverModule(host, root, { exclude = [], i18n = null, page
|
|
|
153
153
|
` const method = request.method.toUpperCase();\n` +
|
|
154
154
|
` if (method !== "GET" && method !== "HEAD") return null;\n` +
|
|
155
155
|
` const url = new URL(request.url);\n` +
|
|
156
|
-
`
|
|
157
|
-
`
|
|
158
|
-
`
|
|
159
|
-
`
|
|
156
|
+
` let doc;\n` +
|
|
157
|
+
` try {\n` +
|
|
158
|
+
` doc = await renderDocument(render, {\n` +
|
|
159
|
+
` shell, url: url.pathname, search: url.search, loaders, baseUrl, i18n: options.i18n ?? null,\n` +
|
|
160
|
+
` loaderContext: { request, query: Object.fromEntries(url.searchParams), locals },\n` +
|
|
161
|
+
` });\n` +
|
|
162
|
+
` } catch (e) {\n` +
|
|
163
|
+
` if (e instanceof Response) return e; // a loader redirected or refused (throw new Response)\n` +
|
|
164
|
+
` throw e;\n` +
|
|
165
|
+
` }\n` +
|
|
160
166
|
` if (!doc) return null;\n` +
|
|
161
167
|
` return new Response(method === "HEAD" ? null : doc.html, {\n` +
|
|
162
168
|
` status: doc.status, headers: { "content-type": "text/html; charset=utf-8", "cache-control": "no-cache" },\n` +
|