我目前正在开发react.js应用程序以及SEO和OG标签,尝试react SSR。我已经上传了 public_html 上的构建,还创建了 server.js 文件并启动了节点 server.js。
如果我在 url 中输入 www.xyz.com 网站正在加载并按预期工作,但对于 SSR,我需要在 url 中插入端口号,如 www.xyz.com:3000。
有没有一种方法可以不将端口号放在React SSR上?
它应该在不添加端口号www.xyz.com的情况下在React SSR上工作吗?
是的,您可以通过使用 Nginx 作为反向代理来实现这一点。这是一个基本配置示例:
server {
listen 80;
server_name www.xyz.com;
location / {
proxy_pass http://localhost:3000; # if this is your Node.js server
client_max_body_size 25M; # the default is 1M so you need this if you have file uploads
}
}