Vue local history refresh page blank problem

Modify hash to history
insert image description here

The added publicPath: '/',
insert image description here
item is to adjust a different server so I made a proxy
insert image description here

module.exports = {
    
    
  //...
  devServer: {
    
    
    proxy: {
    
    
      '/': {
    
    
        target: 'http://localhost:3000',
        // 只需要添加该方法,然后当请求的是html,则重定向到index.html
        bypass: function (req, res, proxyOptions) {
    
    
          if (req.headers.accept.indexOf('html') !== -1) {
    
    
            console.log('Skipping proxy for browser request.');
            return '/index.html';
          }
        },
      },
    },
  },
};

Thanks tree hole ROBOT

Guess you like

Origin blog.csdn.net/wzwzwz555/article/details/129798717