0

I've a situation where I want to route to external site at server-side in my single-page application. I want to redirect at certain condition when my data fetching throws particular status code.

What I've tried -

  1. I could intercept response in the Express middleware using res.statusCode. This is 500 due to any error in code and I can't distinguish the reason at this time.
  2. I tried using <Redirect> from react-dom-router but this seems like doesn't work for external links.

Can you suggest any way to redirect to external link during server-side rendering?

Prakhar
  • 1,096
  • 1
  • 16
  • 41
  • Does this answer your question? [React-Router External link](https://stackoverflow.com/questions/42914666/react-router-external-link) – svltmccc Jan 23 '20 at 11:03
  • I read this. This suggests window.location but this is possible at client side and not server-side. – Prakhar Jan 23 '20 at 11:04
  • You can make redirect using http or any framework (koa, express for example) – svltmccc Jan 23 '20 at 11:05
  • I learn whether to redirect or not while rendering, and express would know only res.status as 500. The actual reason when I want to redirect is when component is rendered. – Prakhar Jan 23 '20 at 11:11

0 Answers0