Vue router is not working on the build version

Viewed 21

I have developed a Vue3 app with only one route. It is working fine on the development version but after "npm run build" the route is not working on the build version.

Here is the vite.config.js file

import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})

Here is the router/index.js file

import { createRouter, createWebHistory } from "vue-router";
import HomeView from "../views/HomeView.vue";

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        {
            path: "/:shop_id",
            name: "home",
            component: HomeView,
        },
    ],
});

export default router;
0 Answers
Related