Created
February 15, 2020 03:03
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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