0

I'm developing a Loopback-based NodeJS app that uses GitHub Passport auth. For my development, I use localhost in my callbackURL setting in providers.json, but I have to change it to the published URL every time I deploy. At the same time, I have to change the same setting on GitHub.

How do you handle such scenarios? Is it possible to put a setting in providers.json? Is it possible to use two applications on GitHub and switch between them?

4

1 回答 1

0

可能您正在文档中加载providers.jsonserver.js喜欢的文件:(https://loopback.io/doc/en/lb3/Configuring-providers.json.html

var config = {};
try {
  config = require('../providers.json');
} catch (err) {
  console.trace(err);
  process.exit(1); // fatal
}

因此,您可以创建两个单独providers.json的文件(例如 providers.dev.json providers.prod.json)并根据例如 NODE_ENV 环境变量加载一个正确的文件

于 2018-06-26T20:47:43.560 回答