Преглед изворни кода

refactor config keys for internal redirerct

Yuki Takei пре 5 година
родитељ
комит
d9a04452d6
2 измењених фајлова са 10 додато и 10 уклоњено
  1. 5 5
      src/server/service/config-loader.js
  2. 5 5
      src/server/service/file-uploader/local.js

+ 5 - 5
src/server/service/config-loader.js

@@ -137,17 +137,17 @@ const ENV_VAR_NAME_TO_CONFIG_INFO = {
     type:    TYPES.BOOLEAN,
     default: false,
   },
-  USE_INTERNAL_REDIRECT: {
+  FILE_UPLOAD_LOCAL_USE_INTERNAL_REDIRECT: {
     ns:      'crowi',
-    key:     'app:useInternalRedirect',
+    key:     'fileUpload:local:useInternalRedirect',
     type:    TYPES.BOOLEAN,
     default: false,
   },
-  INTERNAL_REDIRECT_PATH: {
+  FILE_UPLOAD_LOCAL_INTERNAL_REDIRECT_PATH: {
     ns:      'crowi',
-    key:     'app:internalRedirectPath',
+    key:     'fileUpload:local:internalRedirectPath',
     type:    TYPES.STRING,
-    default: "/growi-internal/",
+    default: '/growi-internal/',
   },
   ELASTICSEARCH_URI: {
     ns:      'crowi',

+ 5 - 5
src/server/service/file-uploader/local.js

@@ -98,20 +98,20 @@ module.exports = function(crowi) {
    */
   lib.canRespond = () => {
     // Check whether to use internal redirect of nginx or Apache.
-    return process.env.FILE_UPLOAD == "local" && lib.configManager.getConfig('crowi', 'app:useInternalRedirect');
+    return process.env.FILE_UPLOAD == 'local' && lib.configManager.getConfig('crowi', 'fileUpload:local:useInternalRedirect');
   };
 
   /**
    * Respond to the HTTP request.
-   * @param {Response} res 
-   * @param {Response} attachment 
+   * @param {Response} res
+   * @param {Response} attachment
    */
   lib.respond = (res, attachment) => {
     // Responce using internal redirect of nginx or Apache.
     const storagePath = getFilePathOnStorage(attachment);
     const relativePath = path.relative(crowi.publicDir, storagePath);
-    const internalPathRoot = lib.configManager.getConfig('crowi', 'app:internalRedirectPath');
-    const internalPath = urljoin(internalPathRoot, relativePath)
+    const internalPathRoot = lib.configManager.getConfig('crowi', 'fileUpload:local:internalRedirectPath');
+    const internalPath = urljoin(internalPathRoot, relativePath);
     res.set('X-Accel-Redirect', internalPath);
     res.set('X-Sendfile', storagePath);
     return res.end();