nginx
location /h5/react_web {
alias /usr/local/nginx/html/h5/react_web/;
# browserHistory模式 404问题
try_files $uri $uri/ /h5/react_web/index.html;
index index.html;
autoindex on;
gzip on;
add_header Access-Control-Allow-Origin '*';
add_header Access-Control-Allow-Methods 'GET, POST, PUT, OPTIONS';
add_header Access-Control-Expose-Headers 'Accept-Ranges, Content-Encoding, Content-Length, Content-Range';
}
node
app.get('*', function (request, response){
response.sendFile(path.resolve(__dirname, 'public', 'index.html'))
})
不管哪种方式都是把请求都转到index.html,而index.html会根据React-Router规则去匹配任何一个route