简体   繁体   English

Node.js网站+反应

[英]Nodejs website + react

I'm new in react world. 我是React World的新手。 So I want to make an website with express + react. 所以我想做一个网站表达+反应。 My question is, I have to make 2 servers 1 to my cliente-side(react) and another to my server-side(express)?? 我的问题是,我必须使2台服务器1到我的客户端(反应),而另一台到我的服务器(表达)? or I can create just 1 server with both, like express + ejs, blade? 或者我只能同时创建1个服务器,例如express + ejs,blade?

(Sorry for my english) (对不起我的英语不好)

Thanks, 谢谢,

You could use only one server if you wanted to. 如果需要,您只能使用一台服务器。 Setup your express server to return your react bundle on one url, all your api requests on other dedicated urls (same goes for static content such as images), and fall back to returning your index.html on all other urls. 设置您的Express服务器,以在一个URL上返回您的react bundle,在其他专用URL上返回所有api请求(对于诸如图像之类的静态内容也是如此),而在所有其他URL上返回index.html。

You can use one server by setting up react to use a proxy. 您可以通过将react设置为使用代理来使用一台服务器。

Read this awesome article. 阅读这篇很棒的文章。 Link 链接

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

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