Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
expressApp.use((req, res) => {
const fileName = getFilenameFromUrl(httpStaticPath, fsClientOutputPath, req.url);
// pre-renderer root route rather than giving index.html.
if (!fileName || fileName === fsClientOutputPath) {
return renderRoute(req, res, preRenderReactApp);
}
isReadable(fileName, readable => {
if (readable) {
return serveStaticFile(res, fileName);
}
return renderRoute(req, res, preRenderReactApp);
});
});
}
this.app.use((req, res, next) => {
const fileName = getFilenameFromUrl(config.publicPath, compiler.outputPath, req.url);
if (!fileName) {
return next();
}
if (fileName === compiler.outputPath) {
return renderRoute(req, res, next);
}
next();
});
}