DEV Community

Discussion on: Build File Upload/Download Functionality with Image Preview using MERN stack

Collapse
 
onidemon profile image
onidemon

Thank you for the tutorial! I have an issue though, the file list page will crash if refreshed and get a cannot get 404 error. Works fine when i refresh the main page but not the list page. Also the file list is giving an error about the favicon.

Refused to load the image because it violates the following Content Security Policy directive: "default-src 'none'". Note that 'img-src' was not explicitly set, so 'default-src' is used as a fallback.

Collapse
 
myogeshchavan97 profile image
Yogesh Chavan

Thanks for pointing out the 404 error. You just need to add the following code inside the server/index.js file before the app.listen call

app.get('*', (req, res) => {
  res.sendFile(path.join(__dirname, '..', 'build', 'index.html'));
});
Enter fullscreen mode Exit fullscreen mode

I have updated the article with these instructions at the end of the article. So please check that out.

Regarding the favicon error, I'm not able to reproduce that. You might not have the favicon.ico file in the public directory so that might have caused that issue. But that is fine, Its not required for the application.

Some comments have been hidden by the post's author - find out more