I've set the values in my env.d.ts but for some reason it's not working, all I'm trying to do is pass data (that is for sure there so I know, I'm saving it to a persistentAtom right now but I want to be sure Astro has it, and I think Middleware is the best way to do that)
import { defineMiddleware } from "astro:middleware";
import { $getAllScenesUnfiltered, $currentScene } from "./store/scene";
export const onRequest = defineMiddleware(async (context, next) => {
// Intercept response data from a request
// optionally, transform the response by modifying `locals`
// E.G. locals.title = "New Title"
if (context.request.url.includes("/dashboard/scenes")) {
const allScenesUnfiltered = await $getAllScenesUnfiltered();
context.locals.allScenesUnfiltered = allScenesUnfiltered;
return next();
}
return next();
// return a Response or the result of calling next()
});
this should set the allScenesUnfiltered in my middleware if that's the correct request URL (looking at making that filtering more specific haha)
but in my env.d.ts I set
import { type Models } from "appwrite"
/// <reference types="astro/client" />
declare namespace App {
interface Locals {
allScenesUnfiltered: Models.Document[];
}
}
which should work right? but I get a TypeError because it's undefined and in my editor it says it isn't a value