Debugging for heroku

This commit is contained in:
Jori Lallo
2016-05-27 00:00:00 -07:00
parent a0e2092e01
commit eab41436a6
2 changed files with 14 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import user from './user';
import atlases from './atlases';
import documents from './documents';
import subdomainRedirect from './middlewares/subdomainRedirect';
import validation from './validation';
const api = new Koa();
@ -39,6 +40,7 @@ api.use(async (ctx, next) => {
}
});
api.use(subdomainRedirect());
api.use(bodyParser());
api.use(validation());

View File

@ -0,0 +1,12 @@
export default function subdomainRedirect(options) {
return async function subdomainRedirectMiddleware(ctx, next) {
console.log(ctx.headers);
if (ctx.headers['x-forwarded-proto'] != 'https') {
ctx.redirect('https://' + ctx.headers.host + ctx.path);
}
else {
return next();
}
}
};