0

When I want to navigate using the <MenuItem> as follows

<MenuItem onTouchTap={() => {this.handleClose()}}>
 <NavLink to="/api/logout">Sign Out</NavLink>
</MenuItem>

that is just putting the mentioned 'to' attribute value /api/logout in the URL linked to the existing route without going to that path and ending up having the link on the browser as http://localhost:3000/api/logout, without going there on the logout route at the nodejs backend server! that is a problem.

Note that I use proxy to directs from 3000 to 5000 as follows

 "proxy": {
    "/api/*": {
      "target": "http://localhost:5000"
    }
  },

Generally speaking, I guess that is because the difference between <Link> and <NavLink>.

If you would like to know more about from where this problem has come out, you can take a look at my previous post how navigate using the MenuItem? material-ui V1 but that is not necessary.

Ken Gregory
  • 7,180
  • 1
  • 39
  • 43
Abdulrahman Alsari
  • 1,667
  • 4
  • 17
  • 28

1 Answers1

0

I worked with me when I updated the code as:

<MenuItem onClick={this.handleClose} ><a href="/api/logout">Sign Out</a></MenuItem> 
Abdulrahman Alsari
  • 1,667
  • 4
  • 17
  • 28