astro 4.5.3 → 4.5.4

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.
@@ -31,6 +31,7 @@ export interface RenderOptions {
31
31
  routeData?: RouteData;
32
32
  }
33
33
  export interface RenderErrorOptions {
34
+ locals?: App.Locals;
34
35
  routeData?: RouteData;
35
36
  response?: Response;
36
37
  status: 404 | 500;
@@ -198,7 +198,7 @@ class App {
198
198
  routeData = this.match(request);
199
199
  }
200
200
  if (!routeData) {
201
- return this.#renderError(request, { status: 404 });
201
+ return this.#renderError(request, { locals, status: 404 });
202
202
  }
203
203
  const pathname = this.#getPathnameFromRequest(request);
204
204
  const defaultStatus = this.#getDefaultStatusCode(routeData, pathname);
@@ -216,10 +216,11 @@ class App {
216
216
  response = await renderContext.render(await mod.page());
217
217
  } catch (err) {
218
218
  this.#logger.error(null, err.stack || err.message || String(err));
219
- return this.#renderError(request, { status: 500 });
219
+ return this.#renderError(request, { locals, status: 500 });
220
220
  }
221
221
  if (REROUTABLE_STATUS_CODES.includes(response.status) && response.headers.get(REROUTE_DIRECTIVE_HEADER) !== "no") {
222
222
  return this.#renderError(request, {
223
+ locals,
223
224
  response,
224
225
  status: response.status
225
226
  });
@@ -263,7 +264,7 @@ class App {
263
264
  * If it is a known error code, try sending the according page (e.g. 404.astro / 500.astro).
264
265
  * This also handles pre-rendered /404 or /500 routes
265
266
  */
266
- async #renderError(request, { status, response: originalResponse, skipMiddleware = false }) {
267
+ async #renderError(request, { locals, status, response: originalResponse, skipMiddleware = false }) {
267
268
  const errorRoutePath = `/${status}${this.#manifest.trailingSlash === "always" ? "/" : ""}`;
268
269
  const errorRouteData = matchRoute(errorRoutePath, this.#manifestData);
269
270
  const url = new URL(request.url);
@@ -281,6 +282,7 @@ class App {
281
282
  const mod = await this.#getModuleForRoute(errorRouteData);
282
283
  try {
283
284
  const renderContext = RenderContext.create({
285
+ locals,
284
286
  pipeline: this.#pipeline,
285
287
  middleware: skipMiddleware ? (_, next) => next() : void 0,
286
288
  pathname: this.#getPathnameFromRequest(request),
@@ -293,6 +295,7 @@ class App {
293
295
  } catch {
294
296
  if (skipMiddleware === false) {
295
297
  return this.#renderError(request, {
298
+ locals,
296
299
  status,
297
300
  response: originalResponse,
298
301
  skipMiddleware: true
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "4.5.3";
1
+ const ASTRO_VERSION = "4.5.4";
2
2
  const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
3
3
  const ROUTE_TYPE_HEADER = "X-Astro-Route-Type";
4
4
  const DEFAULT_404_COMPONENT = "astro-default-404";
@@ -23,7 +23,7 @@ async function dev(inlineConfig) {
23
23
  base: restart.container.settings.config.base
24
24
  })
25
25
  );
26
- const currentVersion = "4.5.3";
26
+ const currentVersion = "4.5.4";
27
27
  if (currentVersion.includes("-")) {
28
28
  logger.warn("SKIP_FORMAT", msg.prerelease({ currentVersion }));
29
29
  }
@@ -36,7 +36,7 @@ function serverStart({
36
36
  host,
37
37
  base
38
38
  }) {
39
- const version = "4.5.3";
39
+ const version = "4.5.4";
40
40
  const localPrefix = `${dim("\u2503")} Local `;
41
41
  const networkPrefix = `${dim("\u2503")} Network `;
42
42
  const emptyPrefix = " ".repeat(11);
@@ -261,7 +261,7 @@ function printHelp({
261
261
  message.push(
262
262
  linebreak(),
263
263
  ` ${bgGreen(black(` ${commandName} `))} ${green(
264
- `v${"4.5.3"}`
264
+ `v${"4.5.4"}`
265
265
  )} ${headline}`
266
266
  );
267
267
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "4.5.3",
3
+ "version": "4.5.4",
4
4
  "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
5
5
  "type": "module",
6
6
  "author": "withastro",