In a nextjs app (classic /pages setup, I'm not using the new /app directory), I want to set an item in the cache in middleware, which can then be read in my pages, components etc in the app. Unfortunately, when I try to read the value back from the cache, it is null.
i.e.:
// middleware.ts
console.log("Setting token cache entry for", guid, JSON.stringify(entry));
cache.put(guid, entry);
// index.tsx getServerSideProps method
console.log("Getting token cache entry for", guid, cache.get(guid));
const entry = cache.get(guid); // ---> entry is null
Console output:
Setting token cache entry for deab99d1-f688-4e9b-a9e49d63b049895a { ... entry object ... }
Getting token cache entry for deab99d1-f688-4e9b-a9e49d63b049895a null