简体   繁体   English

Node,使用PHP api服务器实现Web服务器

[英]Node, React web-server with a PHP api server

When communicating between a Node/React web server and a PHP api server is it best practice to "proxy" all requests by the client (React) through the web server and not directly to the api server? 在Node / React Web服务器和PHP api服务器之间进行通信时,最佳做法是通过Web服务器“代理”客户端(React)的所有请求,而不是直接到api服务器?

Im using universal (isomorphic) React rendered on the Node web server. 我使用在Node Web服务器上呈现的通用(同构)React。 It would also use the api server to build the initial page loads (isomorphic). 它还将使用api服务器来构建初始页面加载(同构)。

That's what I would do. 这就是我要做的。 Actually that's what i'm doing (with a java based backend/api). 实际上这就是我正在做的事情(使用基于java的后端/ api)。 It allows you to hide the real structure of your api and also to eventually parse the result in the node server if needed. 它允许您隐藏api的真实结构,并最终在需要时解析结果在节点服务器中。 Also it allows you to adapt the request method to fit exactly your client services (if for example your api is not exactly sending the data the format and the way you want). 此外,它允许您调整请求方法以完全适合您的客户端服务(例如,如果您的api不是完全按照您希望的格式和方式发送数据)。

For me it seems to be a good practice (and I agree trying to close this question is crazy, this is a good question ...) 对我来说这似乎是一个很好的做法(我同意试图关闭这个问题是疯了,这是一个很好的问题......)

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

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