DEV Community

When Netlify gives you that 404 page

Debbie O'Brien on August 18, 2019

Ever deployed a Vue or Nuxt app to Netlify and got a 404 page when you refresh? Yeah what is all that about. Well if you are working with Vue or ...
Collapse
 
swsalim profile image
Yuyu •

Does it work with ServerMiddleware?

I created a serverMiddleware in my Nuxt app that makes this call for example, /api/fetch?url=<user_submitted_url>. While it works on Heroku, my app gives me 404 error whenever it tries to make that call.

I've tried added fallback: true to generate in the config with no luck.

Do you encounter this before?

Collapse
 
debs_obrien profile image
Debbie O'Brien •

Hey, not come across that no. Did you manage to fix t?

Collapse
 
swsalim profile image
Yuyu •

Yea. Apparently, these issues aren't related. The serverMiddleware doesn't work on static hosting hence it doesn't work on Netlify. I replaced the serverMiddleware with Netlify functions.

Thread Thread
 
debs_obrien profile image
Debbie O'Brien •

Nice 👏

Collapse
 
aviramontesn profile image
AViramontesN •

Hi! Is there a way to fix this with just Vue? I'm not using either Nuxt or Netlify, just plain Vue.js. Would I have to add some kind of fix on the router files? Thank you.

Collapse
 
archyscript profile image
Daniel Dasaolu •

Yes

=> In your public folder
=> create a new file and name it "_redirects"
=> Paste this inside without the quote

"/* /index.html 200"

=> Save your file and push to github
=> It should work this way

Collapse
 
debs_obrien profile image
Debbie O'Brien •

hey sorry not too sure. haven't tried it but am sure it will work somehow. maybe just creating the 404 file.

Collapse
 
rsmithlal profile image
Robert Smith •

Thank you for this! Your redirects snippet really saved the day for me.

Collapse
 
tngeene profile image
Ted Ngeene •

Hey, thank you for the post. would this still work with firebase? I can't seem to find proper documentation for deploying nuxt in spa mode on firebase.

Collapse
 
debs_obrien profile image
Debbie O'Brien •

Hey, I have never worked with firebase but I found this article. hope it helps

Collapse
 
tngeene profile image
Ted Ngeene •

thank you! yes, it did help.

Collapse
 
milos7811 profile image
Miloš Holba •

Thanks ! It's work well !

Collapse
 
alexanderbenerink profile image
adb •

Thank you so much.

Collapse
 
katieadamsdev profile image
Katie Adams •

Saved my butt! Thank you :D