Browse Source

support sub-path

close #90

Signed-off-by: Outsider <outsideris@gmail.com>
Outsider 6 years ago
parent
commit
958be0a6a5
3 changed files with 4 additions and 1 deletions
  1. 2 0
      README.md
  2. 1 1
      app.js
  3. 1 0
      config.js

+ 2 - 0
README.md

@@ -27,6 +27,7 @@ Fill out `config.js` as your infomation.
 * `recaptchaSiteKey`: An optional security measure - if it is set, and `recaptchaSecretKey` is set, then a captcha will be required to get invited.
 * `recaptchaSecretKey`: An optional security measure - if it is set, and `recaptchaSiteKey` is set, then a captcha will be required to get invited.
 * `locale`: Application language (currently `cs`, `de`, `en`, `es`, `fr`, `it`,  `ja`, `ko`, `nl`, `pl`, `pt`, `pt-BR`, `tr`, `zh-CN` and `zh-TW` available).
+* `subpath`: Sub-path in URL. For example, if `/example` is set, it's served in `/example`, not `/`. Default is `/`.
 
 ### Environment Variables
 You can set environment variables directly or in `.env` file.
@@ -40,6 +41,7 @@ If you want to use a `.env` file, create a file in the root called `.env` with t
 - `RECAPTCHA_SITE`: An optional security measure - used to enable reCAPTCHA.
 - `RECAPTCHA_SECRET`: An optional security measure - used to enable reCAPTCHA.
 - `LOCALE`: Application language (currently `cs`, `de`, `en`, `es`, `fr`, `it`, `ja`, `ko`, `nl`, `pl`, `pt`, `pt-BR`, `tr`, `zh-CN` and `zh-TW` available).
+* `SUBPATH`: Sub-path in URL. For example, if `/example` is set, it's served in `/example`, not `/`. Default is `/`.
 
 **Sample**
 

+ 1 - 1
app.js

@@ -35,7 +35,7 @@ app.use(bodyParser.urlencoded({ extended: false }));
 app.use(cookieParser());
 app.use(express.static(path.join(__dirname, 'public')));
 
-app.use('/', routes);
+app.use(config.subpath, routes);
 
 // catch 404 and forward to error handler
 app.use(function(req, res, next) {

+ 1 - 0
config.js

@@ -18,4 +18,5 @@ module.exports = {
   recaptchaSecretKey: process.env.RECAPTCHA_SECRET || null,
   // default locale
   locale: process.env.LOCALE || "en",
+  subpath: process.env.SUBPATH || "/"
 };