Is there any way to serve a custom “Page not found” 404 page in a Vue.js MPA (multipage application) by modifying vue.config.js? (I am not using vue-router)
2
There are 2 answers
2
On
MPA is just a way to create multiple html files each with its own js bundle - essentially multiple independent Vue apps. As there is no router, there is no client-side routing and every request goes directly to the server. So the server is only place where you can detect the situation (unknown resource requested) and return custom 404 page...
I’ve managed to solve this with only
vue.config.js
with the below. I've followed the approach from a previous answer of mine.And
vue.config.js
:It goes without saying, but this only works in production as the routing is done by the web server. When you developed locally, check the 404 page by visiting the 404 page directly.