Branchwell

Skillfarm / website / functions / _middleware.js

1export async function onRequest({ request, next }) {
2 const url = new URL(request.url);
3 const legacyPath = url.pathname === '/waitlist' || url.pathname === '/waitlist/';
4 const alias = url.hostname === 'www.skillfarm.ai';
5 if (legacyPath || alias) {
6 if (legacyPath) url.pathname = '/';
7 if (alias) url.hostname = 'skillfarm.ai';
8 return Response.redirect(url, 308);
9 }
10 return next();
11}