无法将Phusion Passenger与Sails.js/Node.js一起使用POST表单 [英] Cannot POST forms using Phusion Passenger with Sails.js/Node.js

查看:63
本文介绍了无法将Phusion Passenger与Sails.js/Node.js一起使用POST表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用Sails.js编写的网站,我正尝试将其部署到服务器上装有Passenger的服务器,到目前为止,我没有任何运气.尽管所有GET请求均有效,但似乎所有POST请求均未真正到达应用程序.没有乘客,一切都能完美运行.

I have a site written with Sails.js that I'm trying to deploy to a server with Passenger on it, and so far I'm not having any luck. While all GET requests work, none of the POST requests seem to actually make it to the application. Everything works perfectly without Passenger.

测试控制器:

module.exports = TestController =

  show: (req, res) ->
    res.view()

  post: (req, res) ->
    res.send(200)

表格:

form(action='/test', method='POST')
    input(type='text', name='test', placeholder='foo')
    input(type='submit', value='Test')

我在未发送参数的情况下收到Postman的 200:OK 响应,但是一旦添加参数,我什么也没得到.它要么只是挂起,要么向我发送错误的请求:GET和HEAD请求可能没有正文错误.

I get a 200: OK response with Postman when not sending parameters, but as soon as I add parameters I get nothing. It either just hangs, or sends me Bad request: GET and HEAD requests may not have bodies error.

推荐答案

Phusion乘客作者在此处.正如@Edy所说,这与stdin和/dev/null无关.标准输入仅适用于应用本身,不适用于Phusion Passenger流程(这是具有不同标准输入的不同流程).

Phusion Passenger author here. This has got nothing to do with stdin and /dev/null, as @Edy claims. The stdin thing only holds for the app itself, not for the Phusion Passenger process (which is a different process with a different stdin).

相反,这可能是Phusion Passenger中特定于Node.js的错误.在下一个版本4.0.55(发布目标日期:下周星期五)中,我们引入了相当大的Node.js兼容性改进,可以解决您的问题.到目前为止,Phusion Passenger通过模拟其HTTP库来支持Node.js.在4.0.55中,我们放弃了该方法,转而使用了一种新的,更简单的方法,该方法不涉及模拟或修补任何内容.

Instead, it's possible that this is a Node.js-specific bug in Phusion Passenger. In the next version, 4.0.55 (release goal date: next week Friday), we're introducing pretty major Node.js compatibility improvements which may solve your issue. Up until now Phusion Passenger supports Node.js by emulating its HTTP library. In 4.0.55, we've abandoned that approach in favor of a new, much simpler approach that does not involve emulating or patching anything.

如果您好奇4.0.55是否可以解决问题,可以从git中获取Phusion Passenger,并检查git master版本是否适合您.

If you're curious whether 4.0.55 fixes your issue, you can get Phusion Passenger from git and check whether the git master version works for you.

这篇关于无法将Phusion Passenger与Sails.js/Node.js一起使用POST表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆