Skip to content

Cannot disable loopback explorer in production as specified in docs #2121

Closed

Description

@penguinpowernz

The documentation says here and here that you can disable the API Explorer in production by making a file like this:

// server/component-config.json
{
  "loopback-component-explorer": {
    "mountPath": "/explorer"
  }
}

// server/component-config.production.json
{
  "loopback-component-explorer": false
}

And running the API with the NODE_ENV specified, like so:

NODE_ENV=production node .

However, when I do that I get this error:

$ NODE_ENV=production node .
/home/me/src/project/node_modules/loopback-boot/lib/config-loader.js:243
    throw new Error('Cannot apply ' + fileName + ': ' + err);
    ^

Error: Cannot apply /home/me/src/projec/server/component-config.production.json: Cannot merge values of incompatible types for the option `loopback-component-explorer`.
    at mergeComponentConfig (/home/me/src/project/node_modules/loopback-boot/lib/config-loader.js:243:11)
    at mergeConfigurations (/home/me/src/project/node_modules/loopback-boot/lib/config-loader.js:142:5)
    at loadNamed (/home/me/src/project/node_modules/loopback-boot/lib/config-loader.js:76:16)
    at Object.ConfigLoader.loadComponents (/home/me/src/project/node_modules/loopback-boot/lib/config-loader.js:56:10)
    at compile (/home/me/src/project/node_modules/loopback-boot/lib/compiler.js:60:20)
    at bootLoopBackApp (/home/me/src/project/node_modules/loopback-boot/index.js:139:22)
    at Object.<anonymous> (/home/me/src/project/server/server.js:21:1)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)

Has this process changed and the documentation not been updated? Changing false to an empty object doesn't disable the explorer either.

Here are my versions:

{
  "dependencies": {
    "compression": "^1.0.3",
    "cors": "^2.5.2",
    "loopback": "^2.22.0",
    "loopback-boot": "^2.6.5",
    "loopback-component-explorer": "^2.1.0",
    "loopback-connector-redis": "0.0.3",
    "loopback-datasource-juggler": "^2.39.0",
    "serve-favicon": "^2.0.1"
  },
  "devDependencies": {
    "jshint": "^2.5.6"
  }
}

Activity

  1. connormckelvey commented on Mar 22, 2016

    @connormckelvey

    Ran into the same issue. I was able to get it working by using:

    {
      "loopback-component-explorer": {
        "mountPath": false
      }
    }
    
  2. superkhau commented on Mar 22, 2016

    @superkhau
    Contributor

    I'm not sure whether the procedure changed or not. Maybe @bajtos has some insight here?

    @crandmck Can we update the docs to reflect this?

  3. bajtos commented on Mar 23, 2016

    @bajtos
    Member

    This is a duplicate of strongloop/loopback-component-explorer#51 which has been fixed by strongloop/loopback-boot#168 and released as loopback-boot@2.17.0.

    The patch mentioned above adds support for using null value to disable a component (false values is not supported). Here is the correct usage:

    // server/component-config.production.json
    {
      "loopback-component-explorer": null
    }

    @crandmck could you please update the docs?

  4. crandmck commented on Mar 23, 2016

    @crandmck
    Contributor

    Updated both mentions in the doc noted above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions