Vue-template-admin reports error 405 after packaging dist

See if your Vue routing mode is history or hash
1. First change the publicPath under vue.config.js to './'
insert image description here
2. Change the process.env.NODE_ENV under main.js to ===development
insert image description here
if If it is history mode, it needs to cooperate with the backend.
For example, the backend gives you an address that needs to be accessed: /aaa/ Then you modify it under router.js new Router()


const createRouter = () =>
  new Router({
    
    
      mode: 'history', // require service support
      base:'/aaa/',//这是history的路由模式进行添加base  内容和服务器端保持一致
    scrollBehavior: () => ({
    
     y: 0 }),
    routes: constantRoutes,
  });

const router = createRouter();

Then modify the publicPath in vue.config.js
insert image description here
and then ask if there is a problem with the access address of the backend. Find the responsibility of the backend.

Guess you like

Origin blog.csdn.net/weixin_45441173/article/details/128856227