I am using the netlify adater and have the following astro middleware. It is not running on Netlify, what am I doing wrong?
import { defineMiddleware } from 'astro:middleware';
export const onRequest = defineMiddleware(async (context, next) => {
// Get the cookie to check if it exists
let prepr_uid = context.cookies.get('__prepr_uid')?.value;
// If the cookie doesn't exist yet, generate a random ID
if (!prepr_uid) {
prepr_uid = crypto.randomUUID();
context.cookies.set('__prepr_uid', prepr_uid, {
maxAge: 365 * 24 * 60 * 60, // Set for one year (in seconds)
path: '/',
httpOnly: true,
sameSite: 'lax',
});
}
// Store the Prepr Customer ID in locals to make it available
// throughout the request lifecycle
context.locals.preprCustomerId = prepr_uid;
// Get the response
const response = await next();
// Set the header for API requests
response.headers.set('Prepr-Customer-Id', prepr_uid);
return response;
});
This is the adapter config:
// @ts-check
import { defineConfig } from 'astro/config';
import tailwindcss from "@tailwindcss/vite";
import netlify from "<@&1055234544183287879>/netlify";
// https://astro.build/config
export default defineConfig({
vite: {
plugins: [tailwindcss()],
},
output: "server",
edgeMiddleware: true,
trailingSlash: "never",
adapter: netlify({
imageCDN: false,
devFeatures: {
images: false,
environmentVariables: false,
},
}),
});