vue3 history nginx

router/index.js

import { createRouter, createWebHistory } from 'vue-router'
import { routes } from '@/router/routes'

const router = new createRouter({
    history: createWebHistory(import.meta.env.VITE_BASE_URL),
    routes
})

router.beforeEach((to) => {
    console.log('[ROUTER]', to)
})

export default router
 

.env

VITE_BASE_URL=/h5

nginx.conf

server {
        listen 80;
        server_name abc.com;

        root /data/webapps/project-01;
        index index.html;

        location /h5/ {
                try_files $uri $uri/ /h5/index.html?$query_string;
        }


        include error.conf;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章