Astro.locals is not serializable
此错误来自旧版本的 Astro,已不再使用。如果你无法将项目升级到新版本,那么你可以查阅 未维护的旧文档快照 以获取帮助。
LocalsNotSerializable:在路径 “
HREF
” 下存储的Astro.locals
中的信息不可序列化。请确保只存储可序列化的数据。(E03034)
哪里发生了错误?
Section titled “哪里发生了错误?”在开发模式下,当用户尝试将不可序列化的内容存储在 locals
中时,会抛出该错误。
例如:
import { defineMiddleware } from "astro/middleware";
export const onRequest = defineMiddleware((context, next) => { context.locals = { foo() { alert("Hello world!") } }; return next();});