mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 06:07:21 +01:00
expose new client at /new-app, can be enabled in prod setting a flag
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
import locals from '../../middlewares/locals';
|
||||
import _ from 'lodash';
|
||||
import md from 'habitica-markdown';
|
||||
import nconf from 'nconf';
|
||||
|
||||
let api = {};
|
||||
|
||||
const IS_PROD = nconf.get('IS_PROD');
|
||||
const TOTAL_USER_COUNT = '1,500,000';
|
||||
const LOADING_SCREEN_TIPS = 32;
|
||||
const IS_NEW_CLIENT_ENABLED = nconf.get('NEW_CLIENT_ENABLED') === 'true';
|
||||
|
||||
api.getFrontPage = {
|
||||
method: 'GET',
|
||||
@@ -82,5 +85,19 @@ api.redirectExtensionsPage = {
|
||||
},
|
||||
};
|
||||
|
||||
// All requests to /new_app (expect /new_app/static) should serve the new client in development
|
||||
if (IS_PROD && IS_NEW_CLIENT_ENABLED) {
|
||||
api.getNewClient = {
|
||||
method: 'GET',
|
||||
url: /^\/new-app($|\/(?!(static\/.?|static$)))/,
|
||||
async handler (req, res) {
|
||||
if (!(req.session && req.session.userId)) {
|
||||
return res.redirect('/static/front');
|
||||
}
|
||||
|
||||
return res.sendFile('./dist-client/index.html', {root: `${__dirname}/../../../../`});
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = api;
|
||||
|
||||
Reference in New Issue
Block a user