Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

rest-countries-api-with-color-theme-switcher

Ammar Jalabi• 270

@AmmarCode

Desktop design screenshot for the REST Countries API with color theme switcher coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
  • API
4advanced
View challenge

Design comparison


SolutionDesign

Solution retrospective


Hi everyone, I completed my REST-COUNTRIES-API challenge. I faced difficulty when I go to a country details page, if I hit refresh, the site crashes with a 404 status code.

After some debugging and research I found that it was related to client-side routing, and there are multiple ways to deal with that issue, one of which is to use hash-router instead of browser-router, but that's not recommended.

The way I chose to take is Netlify specific, add a _redirects file to the public folder in my react app that redirects all the routes to the index.html. You can find more details in this article: https://dev.to/dance2die/page-not-found-on-netlify-with-react-router-58mc More information about redirects on Netlify's documentation: https://docs.netlify.com/routing/redirects/

Happy coding!!

Community feedback

Please log in to post a comment

Log in with GitHub
Discord logo

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord