Debugging for heroku
This commit is contained in:
@ -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());
|
||||
|
||||
|
12
server/api/middlewares/subdomainRedirect.js
Normal file
12
server/api/middlewares/subdomainRedirect.js
Normal 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();
|
||||
}
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user