Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions functions/_middleware.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export async function onRequest(context) {
const { env, next } = context;

const IS_DEPRECATED = env.DEPRECATED !== 'false';

if (IS_DEPRECATED) {
return new Response(
'This site has been deprecated. Please use main-site.',
{
status: 410,
headers: {
'Content-Type': 'text/plain; charset=utf-8',
'Cache-Control': 'no-store',
},
}
);
}

return await next();
}