Reputation: 4463
Not sure why when I run my Vue app locally, the navbar links works. But after deploy, it gets an error
404 - File or directory not found.
The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.
When I inspect it, I get:
<a data-v-5e628c52="" href="/students" class="md-opjjpmhoiojifppkkcdabiobhakljdgm_doc">Students</a>
<a data-v-9b8548a0="" href="/students" class="md-opjjpmhoiojifppkkcdabiobhakljdgm_doc">Students</a>
This is my App.vue:
<template>
<div id="app">
<Header
name=""
:navLinks="[
{
name: 'Home',
link: '/',
dropdown: false
},
{ name: 'Students', link: '/students', dropdown: false }
]"
/>
<router-view />
<Footer />
</div>
</template>
<script>
import Header from "./components/layout/Header";
export default {
name: "app",
components: {
Header
}
};
</script>
and my Header.vue
<template>
<div>
<nav>
<div v-if="name" id="logo">
{{ name }}
</div>
<div v-else id="logo">
<img alt="Vue logo" src="../../assets/stevelogo.png" width="50" />
</div>
<ul class="nav-links">
<li v-for="list in navLinks" :key="list.key">
<a v-if="list.dropdown === false" :href="list.link">{{
list.name
}}</a>
<div class="dropdown-link" v-else>
<a :href="list.link">
{{ list.name }}
<span>↓</span>
</a>
</div>
</li>
</ul>
<div v-on:click="openMobileNav()" id="burger">
<div class="line1"></div>
<div class="line2"></div>
<div class="line3"></div>
</div>
</nav>
</div>
</template>
<script>
export default {
name: "Header",
};
</script>
Upvotes: 0
Views: 497
Reputation: 479
There are two types of environment in a Vue Application (or React or Angular)
While you are running a development server on port 8000, all requests are handled by the development server BUT when you deploy your application all request must go into dist/index.html OR build/index.html (Depending on your build configuration)
You can try to deploy application on netlify.com with following build command
CI='' npm run build && echo "/* /index.html 200" > dist/_redirects
Else for you current deployment, you need to change configuration of the deployment so that all requests after /* goes to dist/index.html
Upvotes: 1