Question

Vue router 404 error on refreshing site or direct link access - DO App

Hi everyone,

I have smoothly deployed a VueJS app on a DO App as Static Site. App and routes works fine. But there is one major problem, when someone tries to access router link directly or refresh the page - app throws 404 error.

I have found in VueJS official documentation info that I should create catch-all fallback on the server side: HTML5 History Mode Unfortunately I have no clue how to implement it on DO App. Should it be some modification to App Spec file?

Anyone here have some solution for this problem?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Sri Charan Madhavapeddi
DigitalOcean Employee
DigitalOcean Employee badge
January 20, 2022
Accepted Answer

Hello @askAxolotl ,

I understand that you are experiencing a 404 error on the app due to a routing issue. You have to set the catchall_document to index.html to fix this issue. There are 2 methods to set the catchall_document.

=======

  1. Using Cloud panel UI: Log in and click on App > Settings >> click on component name > scroll down to Custom page > Edit Custom page and select Catchall > Enter index.html in the page name block > save

  2. Using App Spec: You can the catchall_document to index.html in-app spec.

Here’s the documentation link which will help you in updating your app: https://www.digitalocean.com/docs/app-platform/references/app-specification-reference/ https://www.digitalocean.com/docs/app-platform/references/command-line/

=======

We have discussed a similar issue in our community link below: https://www.digitalocean.com/community/questions/react-router-and-app-platform-problems?answer=64988 https://www.digitalocean.com/community/questions/digital-ocean-apps-spa-application

Hope this helps!

Cheers, Sri Charan

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel