Skip to content

Commit

Permalink
allow vue-router urls to work in frontend image
Browse files Browse the repository at this point in the history
Added 404 fallback in Vue
  • Loading branch information
rgaudin committed Aug 23, 2023
1 parent 37431e7 commit 01caa64
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
7 changes: 7 additions & 0 deletions frontend/nginx-default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,12 @@ server {
location / {
root /user/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
}

error_page 404 /index.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
6 changes: 6 additions & 0 deletions frontend/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import CollectionsView from '@/views/CollectionsView.vue'
import { createRouter, createWebHistory } from 'vue-router'
import FrequentlyAskedQuestions from '@/components/FrequentlyAskedQuestions.vue'
import ContactPage from '@/components/ContactPage.vue'
import NotFoundView from '@/views/NotFoundView.vue'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
Expand Down Expand Up @@ -37,6 +38,11 @@ const router = createRouter({
path: '/',
name: 'start',
component: StartView
},
{
path: '/:pathMatch(.*)*',
name: '404',
component: NotFoundView
}
]
})
Expand Down
26 changes: 26 additions & 0 deletions frontend/src/views/NotFoundView.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<template>
<div class="d-flex flex-column vh-100">
<div class="flex-shrink-1">
<div class="mt-5">
<SloganComponent />
</div>
<div class="mt-5">
<Suspense>
<div class="container">
<h2>404 Error: Not Found</h2>
<p>We could not match your request with a valid document.</p>
</div>
</Suspense>
</div>
</div>
<FooterComponent />
</div>
</template>

<script setup lang="ts">
import FooterComponent from '@/components/FooterComponent.vue'
import SloganComponent from '@/components/SloganComponent.vue'
import FrequentlyAskedQuestions from '@/components/FrequentlyAskedQuestions.vue'

Check warning on line 23 in frontend/src/views/NotFoundView.vue

View workflow job for this annotation

GitHub Actions / check-frontend-qa

'FrequentlyAskedQuestions' is defined but never used
import DragToStartProjectComponent from '@/components/DragToStartProjectComponent.vue'

Check warning on line 24 in frontend/src/views/NotFoundView.vue

View workflow job for this annotation

GitHub Actions / check-frontend-qa

'DragToStartProjectComponent' is defined but never used
import StatementsComponent from '@/components/StatementsComponent.vue'

Check warning on line 25 in frontend/src/views/NotFoundView.vue

View workflow job for this annotation

GitHub Actions / check-frontend-qa

'StatementsComponent' is defined but never used
</script>
1 change: 1 addition & 0 deletions frontend/src/views/StartView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
</template>

<script setup lang="ts">
import FooterComponent from '@/components/FooterComponent.vue'
import CollectionsView from './CollectionsView.vue'
import HomeView from '@/views/HomeView.vue'
import { type Project } from '@/constants'
Expand Down

0 comments on commit 01caa64

Please sign in to comment.