简体   繁体   English

从sails.js服务角度2 CLI

[英]Serve angular 2 CLI from sails.js

I read through this blog post and was successfully able to get the "hello world" page to run. 我通读了这篇博客文章,并成功地使“ hello world”页面可以运行。 I couldn't figure out routing, so I decided to generate an entire angular 2 CLI app and stick it in my assets folder. 我无法确定路由,所以我决定生成一个完整的angular 2 CLI应用程序并将其粘贴在我的资产文件夹中。

Is there a way to tell sails to route all calls to /admin to that angular app? 有没有办法告诉帆将对/admin所有呼叫路由到该角度应用程序? Also, if there is a better way to do this, all I am trying to do is create an angular 2 admin app for a sails api. 另外,如果有更好的方法可以执行此操作,那么我要做的就是为Sails API创建一个angular 2管理应用程序。

I recommend you use the 2 tier aproach. 我建议您使用2层方法。 And host your angular app in one place and the sails api on another. 并将您的角度应用程序托管在一个地方,将帆API托管在另一个地方。

For example you can ng build --prod take all the files from the dist folder and host in a static file server, like Amazon S3. 例如,您可以ng build --prod从dist文件夹中获取所有文件,并将其托管在静态文件服务器(如Amazon S3)中。

And host your sails.js api in some cloud server like Digital Ocean, Amazon, Azure, Heroku, Google or any other that suports node. 并将您的sails.js api托管在一些云服务器中,例如Digital Ocean,Amazon,Azure,Heroku,Google或其他任何支持节点的云服务器。

Since the angular don't need nothing from the server to run it can be anywhere and point to the api to get the data. 由于有角度的服务器不需要任何东西来运行它,因此它可以在任何地方指向api来获取数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM