首页 > 解决方案 > Add sails route path to default URL

问题描述

I have a node server that uses Sails framework.

When I run, it returns this message:

info: To see your app, visit http://localhost:1337
info: To shut down Sails, press <CTRL> + C at any time.

Is possible to add a route path to the default URL?

Instead of http://localhost:1337, use http://localhost:1337/test/

I tried to run with npm start sails lift --appPath=/test/ but does not do anything.

标签: javascriptnode.jspathroutessails.js

解决方案


如果您希望 Sails.js 在测试期间提升到特定页面,您可以创建一个新的视图操作(或者view-homepage-or-redirect如果您下载了应用程序,则使用)然后在操作中您可以设置

if (sails.config.environment !== 'production') {
   throw {redirect:'/test'};
}

如果你最终为此做了一个新动作,别忘了把它添加到你的routes.js


推荐阅读