erikras / react-redux-universal-hot-example

A starter boilerplate for a universal webapp using express, react, redux, webpack, and react-transform
MIT License
12.01k stars 2.5k forks source link

How do I do a permanent 301 redirect asynchronously after fetching data from the api #1243

Open skywickenden opened 7 years ago

skywickenden commented 7 years ago

My site is a rebuild and I need to put permanent '301' redirects in place after fetching some data.

EG. user requests /oldurl/old-reference.

This is routed to a component for handling it. I use asyncConnect to make a call to the API through redux. When this returns I need to make a 301 redirect to the new url: newurl/new-reference-from-api. How do I communicate this back up to server.js after redux receives the data?

All this needs to happen in the initial server side rendering. The old urls are only accessed from external locations such as search engines.