Netlify TOML文件中的默认路径设置

时间:2018-08-27 09:58:34

标签: node.js angular netlify

我有带NodeJS后端的Angular-JS应用。我想将站点部署到Netlify,后者不支持在后端进行nodeJS部署。这就是为什么我要在toml文件中配置“ app.set”和“ app.use”信息,但不知道该怎么做。 任何人都可以帮忙吗?

NodeJS代码

// view engine setup
app.set('views', path.join(__dirname, '../frontend/views'));
app.set('view engine', 'ejs');

app.use(logger('dev'));

// Use the passport package in our application
app.use(passport.initialize());
require('./../frontend/config/passport')(passport);

app.use('/api/admin/banners/',bannersApi);
app.use('/api/vendor/cms/',cmsApi);
app.use('/api/ebay', eBayApi);

app.get('/admin', (req, res, next) => {
    res.render('admin/index', { title: "Chirp"});
});
app.get('/admin/*', (req, res, next) => {
    res.render('admin/index', { title: "Chirp"});
});

netlify.toml

[build]
  # This is the directory to change to before starting a build.
  base    = "frontend/"
  # NOTE: This is where we will look for package.json/.nvmrc/etc, not root.
  # This is the directory that you are publishing from (relative to root of     your repo)
  publish = "frontend/"
  # This will be your default build command
  # command = "gulp"

# A basic redirects rule
[[redirects]]
  from = "/*"
  to = "/index.ejs"
  status = 200
  force = true

1 个答案:

答案 0 :(得分:1)

在我看来,您正在尝试将服务器应用程序部署为netlify,仅支持客户端应用程序。如果您希望将后端功能与客户端应用程序绑定在一起,则可以利用他们的functions产品。