Skip to content

Instantly share code, notes, and snippets.

@brendonjohn
Created February 15, 2020 03:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brendonjohn/f82d22511f1d168be05225608dbd1ff8 to your computer and use it in GitHub Desktop.
Save brendonjohn/f82d22511f1d168be05225608dbd1ff8 to your computer and use it in GitHub Desktop.
redirect example for when am express app that uses @react-ssr/express is mounted as a sub application
import path from 'path'
const applyPrefixToRoute = (prefix) => (request, response) => {
console.log('received request for: ', request.url)
const redirectTo = path.join(prefix, request.url)
console.log('redirecting to: ', redirectTo)
response.redirect(redirectTo)
}
const applyRouteHack = (app, routePrefix) => {
app.get('/_react-ssr/*.css', applyPrefixToRoute(routePrefix))
app.get('/_react-ssr/*.js', applyPrefixToRoute(routePrefix))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment