9e5fafa2b2
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
40 lines
1,008 B
Text
40 lines
1,008 B
Text
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
exports[`Serverless prerender build successfully the middleware edge file 1`] = `
|
|
"// test/fixtures/middleware/src/vercel-edge-middleware.js
|
|
function vercel_edge_middleware_default({ request, context }) {
|
|
return {
|
|
title: \\"Hello world\\"
|
|
};
|
|
}
|
|
|
|
// test/fixtures/middleware/dist/middleware2.mjs
|
|
var onRequest = async (context, next) => {
|
|
const response = await next();
|
|
return response;
|
|
};
|
|
|
|
// <stdin>
|
|
import { createContext, trySerializeLocals } from \\"astro/middleware\\";
|
|
async function middleware(request, context) {
|
|
const url = new URL(request.url);
|
|
const ctx = createContext({
|
|
request,
|
|
params: {}
|
|
});
|
|
ctx.locals = vercel_edge_middleware_default({ request, context });
|
|
const next = async () => {
|
|
const response = await fetch(url, {
|
|
headers: {
|
|
\\"x-astro-locals\\": trySerializeLocals(ctx.locals)
|
|
}
|
|
});
|
|
return response;
|
|
};
|
|
return onRequest(ctx, next);
|
|
}
|
|
export {
|
|
middleware as default
|
|
};
|
|
"
|
|
`;
|