[英]Adding an entire working AngularJs 1.7 app to a Node.js Server
I have a node.js server : 我有一个node.js服务器:
08/07/2019 17:52 14 545 app.js
06/07/2019 21:04 <DIR> node_modules
06/07/2019 21:04 51 299 package-lock.json
06/07/2019 21:04 496 package.json
08/07/2019 17:53 <DIR> public
08/07/2019 12:52 <DIR> uploads
I have en entire angularJs website with a front end router that is working well, and is using the node app.js file as a back end for mongoDb, with some $http queries. 我在整个angularJs网站上都有一个运行良好的前端路由器,并且正在使用node app.js文件作为mongoDb的后端,并带有一些$ http查询。
This angularJs website is hosted on a external apache server , and make calls to the node.js server through https using an angularjs service. 这个angularJs网站托管在外部apache服务器上 ,并使用angularjs服务通过https调用node.js服务器。
This is the angularJs app : 这是angularJs应用程序:
08/07/2019 17:57 15 398 app.js
17/06/2019 19:45 <DIR> bower_components
05/06/2019 15:59 70 cache.manifest
17/06/2019 19:45 <DIR> class
17/06/2019 19:45 <DIR> connexions
17/06/2019 19:45 <DIR> controllers
17/06/2019 19:45 <DIR> css
17/06/2019 19:45 <DIR> directives
17/06/2019 19:45 <DIR> img
08/07/2019 17:12 14 984 index.html
07/07/2019 20:51 <DIR> js
17/06/2019 19:45 <DIR> librairies
17/06/2019 19:45 <DIR> libs
17/06/2019 19:45 <DIR> mail
17/06/2019 19:40 <DIR> myApp
17/06/2019 21:14 <DIR> services
06/07/2019 20:36 <DIR> tickets
07/07/2019 20:46 <DIR> vues
Now, i have transfered the whole angularJs app to the node.js server PUBLIC directory. 现在,我已经将整个angularJs应用程序转移到了node.js服务器的PUBLIC目录中。
But, when i type 但是,当我键入
node app.js
I can't see the angularJs app working, when browsing to 浏览到以下位置时,我看不到angularJs应用程序正常工作
http://localhost:3000/public
I would really appreciate if somebody has an idea on how to make it work ? 如果有人对如何使其工作有任何想法,我将不胜感激。
How could I reach the angularJs website in one go, from the node.js server ? 如何从node.js服务器一口气访问angularJs网站? Is it possible ? 可能吗 ?
I don't want to redo all of the routes ! 我不想重做所有路线! I don't need it, it is all done by the front end . 我不需要它,这都是在前端完成的。 I only need node.js to display the index.html and to run the whole front end app . 我只需要node.js来显示index.html并运行整个前端应用程序。
All the thing is in app.js
there. 一切都在app.js
中。
You should add static routing in nodejs server config. 您应该在nodejs服务器配置中添加静态路由。
app.use(express.static('public'))
Then, the nodejs server will serve angularjs's entry point - public/index.html
. 然后,nodejs服务器将服务angularjs的入口点-public public/index.html
。
Please refer to this for detailed explanation. 请参阅此内容以获取详细说明。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.