This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
outline/server/middlewares/apexRedirect.js

16 lines
348 B
JavaScript

// @flow
import type { Context } from 'koa';
export default function apexRedirect() {
return async function apexRedirectMiddleware(
ctx: Context,
next: () => Promise<*>
) {
if (ctx.headers.host === 'getoutline.com') {
ctx.redirect(`https://www.${ctx.headers.host}${ctx.path}`);
} else {
return next();
}
};
}