mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Deprecate API v2 (#7761)
* deprecate api-v2 * remove v2 test helpers * remove unused string
This commit is contained in:
17
website/server/middlewares/static.js
Normal file
17
website/server/middlewares/static.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import express from 'express';
|
||||
import nconf from 'nconf';
|
||||
import path from 'path';
|
||||
|
||||
const IS_PROD = nconf.get('IS_PROD');
|
||||
const MAX_AGE = IS_PROD ? 31536000000 : 0;
|
||||
const PUBLIC_DIR = path.join(__dirname, '/../../client');
|
||||
const BUILD_DIR = path.join(__dirname, '/../../build');
|
||||
|
||||
module.exports = function staticMiddleware (expressApp) {
|
||||
// TODO move all static files to a single location (one for public and one for build)
|
||||
expressApp.use(express.static(BUILD_DIR, { maxAge: MAX_AGE }));
|
||||
expressApp.use('/common/dist', express.static(`${PUBLIC_DIR}/../../common/dist`, { maxAge: MAX_AGE }));
|
||||
expressApp.use('/common/audio', express.static(`${PUBLIC_DIR}/../../common/audio`, { maxAge: MAX_AGE }));
|
||||
expressApp.use('/common/img', express.static(`${PUBLIC_DIR}/../../common/img`, { maxAge: MAX_AGE }));
|
||||
expressApp.use(express.static(PUBLIC_DIR));
|
||||
};
|
||||
Reference in New Issue
Block a user