大佬教程收集整理的这篇文章主要介绍了node.js – 如何设置Apache ProxyPass以保留Express路由,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<IfModule mod_proxy.c> Proxyrequests Off ProxyPass /node http://localhost:3000/ </IfModule>
Express应用程序如下所示:
var express = require('express'); var app = express(); var router = express.Router(); router.route('/route/:id').get(function (req,res) { res.json({ description: 'Welcome to a route with an ID' }); }); router.route('/route').get(function (req,res) { res.json({ description: 'Welcome to the normal route' }); }); router.route('/').get(function (req,res) { res.json({ data: 'Welcome to the app' }); }); app.use('/',router); app.listen(3000);
当我将浏览器定向到http://myserver.com/node时,我收到了响应{data:’Welcome to the app’},这很好.虽然,当我尝试去http://myserver.com/node/route或http://myserver.com/node/1210时,我得到一个错误无法获取//路线.
有什么想法我如何更新我的Apache配置以保留Express路线?
我在CentOS上运行Apache 2.4.6.
以上是大佬教程为你收集整理的node.js – 如何设置Apache ProxyPass以保留Express路由全部内容,希望文章能够帮你解决node.js – 如何设置Apache ProxyPass以保留Express路由所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。