Subdomain redirecting

This commit is contained in:
Jori Lallo
2016-05-27 00:06:36 -07:00
parent eab41436a6
commit a0f86f5ed4
3 changed files with 6 additions and 4 deletions

View File

@ -4,6 +4,8 @@ import Koa from 'koa';
import Router from 'koa-router';
import sendfile from 'koa-sendfile';
import subdomainRedirect from './middlewares/subdomainRedirect';
const koa = new Koa();
const router = new Router();
@ -33,6 +35,8 @@ if (process.env.NODE_ENV === 'production') {
const stats = await sendfile(ctx, path.join(__dirname, '../dist/index.html'));
if (!ctx.status) ctx.throw(httpErrors.NotFound());
});
koa.use(subdomainRedirect());
} else {
router.get('*', async (ctx) => {
const stats = await sendfile(ctx, path.join(__dirname, './static/dev.html'));