Krakenjs如何将除api调用之外的所有请求路由到index.html?
如何将所有请求路由到index.html,除了一些API调用和一些页面。 因为kraken路由的方式是基于控制器的目录,所以如果我这样做
// /controller/index.js app.get('*', function(){ res.sendFile(__dirname + '/public/index.html'); });
kraken会把我所有的请求路由到index.html,包括/ controller / api目录下的api调用。 所以我怎样才能让kraken把/ api这样的请求路由到/controller/api/index.js,其余的到/public/templates/index.html?
我把它作为中间件之后的路由器(使用优先级,以确保它结束在正确的地方)
module.exports = function setupJustServeTheAppEverywhere() { return function (req, res, next) { res.sendFile(__dirname + '/public/index.html'); } };
并有configuration负载。
- SPA应该使用Ajax还是socket.io?
- 如何在没有Cookie的情况下在SPA中使用第三方authentication服务?
- 在SPA(单页面应用程序)中使用node.js + express.js在服务器端dynamic生成内容的SEO
- 无法在Nodejs中执行fileupload程序
- 用于生成PDF的React JS / Node JS / Java RESTful API
- 如何使用Express.js正确设置单页应用程序的路线?
- Angular2 POST Observable Request返回一个不可读的JSON对象
- 如何用Express后台构build多个布局的Angular JS
- 为什么使用Bower.js如果npm工作正常?