• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Why does “Cannot GET” appear when I access the page on google using node, but the route in React works?

Resolved: Why does “Cannot GET” appear when I access the page on google using node, but the route in React works?

0
By Isaac Tonny on 16/03/2023 Issue
Share
Facebook Twitter LinkedIn

In this post, we will see how to resolve Why does “Cannot GET” appear when I access the page on google using node, but the route in React works?

Question:

I’m building an application with Reactjs and Nodejs and I’ve built all my routes using React-Router-Dom
`
When I move between my pages using the front-end buttons, the site works correctly because either I use the functionality <Link to={}> </Link/> or I use UseNavigate();.
But I’m having problems when I access the site directly with the link, I’ll show you a picture of when I use the button on the page: Image Here
When I access the same link writing in the browser itself, this message appears to me: Second Image Here
The browser recognizes it as another type of route.
I’m using Nodejs for my Back-End and I really don’t know what to do about it. Can anyone help me, why I don’t know if I can fix it using Reactjs or Nodejs?

Best Answer:

Are you rendering your React build using NodeJS? If so, you’ll have to instruct your backend to always render index.html.
You’ll have to do something like this in your server:

If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com

javascript node.js react-hooks reactjs
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: How to compare two text files and and change the sign of the data in powershell?

27/03/2023

Resolved: Java Virtual Machines deleted

27/03/2023

Resolved: PyCharm cannot see my newly compiled .pyc see on import

27/03/2023

Comments are closed.

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.