zoukankan      html  css  js  c++  java
  • 前端项目路由使用browserHistory不能刷新,页面刷新错误,

    前端spa项目,使用

    browserHistory

    刷新后页面错误

    node 服务器设置

    app.use(function(err, req, res, next) {
    // set locals, only providing error in development
    res.locals.message = err.message;
    res.locals.error = req.app.get('env') === 'development' ? err : {};
    
    //render the error page
    res.status(err.status || 500);
     //解决项目部署后刷新错误的问题
    res.sendFile(path.join(__dirname,'public','index.html'))
    
    
    });
    

     nginx 服务器设置

    server{
      listen  80;
      server_name location;
      root  yourProject;
      index index.html index.htm;
      location / {
        try_files $uri/  /index.html =404
      }              
      location ^~ /api {
        rewrite "api/(.*)$" /api/$1 break;
        #proxy_pass   
         proxy_set_header Remote_Addr $remote_addr;  
         proxy_set_header X-Real-IP   $remote_addr;  
         proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;  
     }
    
    }
    

      

  • 相关阅读:
    Git

    学而不记则徒劳无功
    Redis基础
    哈希表
    第一个Python程序
    Python 环境搭建 基于 Windows
    执行数据库的插入操作 insert
    Eclipse连接到My sql数据库的操作总结/配置数据库驱动
    数据库 (一)
  • 原文地址:https://www.cnblogs.com/anin/p/14607259.html
Copyright © 2011-2022 走看看