Skip to content

Latest commit

 

History

History
37 lines (29 loc) · 1.37 KB

File metadata and controls

37 lines (29 loc) · 1.37 KB
title Astro.locals is not serializable
i18nReady true
githubURL https://github.com/withastro/astro/blob/main/packages/astro/src/core/errors/errors-data.ts

import DontEditWarning from '~/components/DontEditWarning.astro'

:::caution[Deprecated] This error is from an older version of Astro and is no longer in use. If you are unable to upgrade your project to a more recent version, then you can consult unmaintained snapshots of older documentation for assistance. :::

LocalsNotSerializable: The information stored in Astro.locals for the path "HREF" is not serializable. Make sure you store only serializable data. (E03034)

What went wrong?

Thrown in development mode when a user attempts to store something that is not serializable in locals.

For example:

import {defineMiddleware} from "astro/middleware";
export const onRequest = defineMiddleware((context, next) => {
  context.locals = {
    foo() {
      alert("Hello world!")
    }
  };
  return next();
});