Test project: react-demo
server { listen 8080; # server_name your.domain.com; root /home/root/react-demo/dist; index index.html index.htm; location / { try_files $uri $uri/ /index.html; } location ^~ /assets/ { gzip_static on; expires max; add_header Cache-Control public; } error_page 500 502 503 504 /500.html; client_max_body_size 20M; keepalive_timeout 10; } Execute sudo service nginx restart to restart the Nginx service. Access the project, http://IP:8080/ Note: 1. If you configure the domain name, port 80 is required. After success, you can access the project by simply accessing the domain name 2. If you use the browserHistory mode of React-Router, please add the following configuration to the Nginx configuration: location / { try_files $uri $uri/ /index.html; } Principle, because our project has only one root entry, when entering a URL like /home, the page cannot be found. In this case, nginx will try to load index.html. After loading index.html, react-router will work and match the /home route we entered, thereby displaying the correct home page. If the project in browserHistory mode is not configured with the above content, a 404 error will occur. Please refer to the react-router documentation: https://react-guide.github.io/react-router-cn/docs/guides/basics/Histories.html Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links You may also be interested in:
|
<<: jQuery realizes the effect of theater seat selection and reservation
>>: The latest version of MySQL5.7.19 decompression version installation guide
An index is a sorted data structure! The fields t...
1. Docker pulls the image docker pull mysql (pull...
This article shares the specific code for JavaScr...
As we all know, the web pages, websites or web pag...
1. Introduction This article will show you how to...
It took me half an hour to write the code, and th...
Optimization ideas There are two main optimizatio...
Transactional Characteristics 1. Atomicity: After...
<base target=_blank> changes the target fram...
I have been relearning HTML recently, which can be...
The network configuration of Host Only+NAT mode u...
Special note: Only the Swoole extension is instal...
need: Merge identical items of one field and sort...
This is the effect to be achieved: You can see th...
0x00 Introduction A few months ago, I found a vul...