Saturday, 18 March 2017

React Router with Express Router

I am trying to create an isomorphic app with react router and express router. What I want to achieve is handle all routes with React Router except few specific routes that I want express to handle it separately and send the response back to react on client side.

What I have in express right now is this -

app.get('*', (req, res) => {
  res.sendFile('index.html');
});

Ideally I would want something like following -

app.post('someroute', (req, res) => {
  res.send();
});

// Handle Every Other route with React

app.get('*', (req, res) => {
  res.sendFile('index.html');
});

Could any one guide me with better resource to learn to achieve the above.

Thank You



via Rockr

No comments:

Post a Comment