[英]Sails.js Single Page Application (SPA) — redirect all missing/unused routes to a single controller action
I'm developing a single page application (SPA) using Sails.js as a backend. 我正在使用Sails.js作为后端开发单页面应用程序(SPA)。 All I want is to redirect all routes to a single controller action.
我想要的只是将所有路由重定向到单个控制器操作。
However, when I do the following: 但是,当我执行以下操作时:
// config/routes.js
module.exports.routes = {
'GET *': 'MainController.application'
};
All requests are getting redirected to my application route, even for static files like CSS/JavaScript, etc. Is there an easy way to fallback to my application route when there is no other means to handle it? 所有请求都被重定向到我的应用程序路由,即使对于CSS / JavaScript等静态文件也是如此。当没有其他方法可以处理它时,是否有一种简单的方法可以回退到我的应用程序路由?
I want: 我想要:
After thorough re-reading of the docs I've found a skipAssets
route parameter. 在彻底重新阅读文档后,我发现了一个
skipAssets
路由参数。
Here's my new configuration: 这是我的新配置:
// config/routes.js
module.exports.routes = {
'GET *': {
controller: 'MainController',
action: 'application',
skipAssets: true
}
};
Looks like it's working as required. 看起来它按要求工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.