@mapbox/batfish
Version:
The React-powered static-site generator you didn't know you wanted
25 lines (20 loc) • 630 B
JavaScript
//
;
const historyApiFallback = require('connect-history-api-fallback');
const stripSiteBasePath = require('./strip-site-base-path');
function startMiddleware(
batfishConfig
) {
const stripAssets = (req , res , next ) => {
if (req.url.startsWith(batfishConfig.publicAssetsPath)) {
req.url = req.url.replace(batfishConfig.publicAssetsPath, '') || '/';
}
next();
};
return [
historyApiFallback(),
stripSiteBasePath(batfishConfig.siteBasePath),
stripAssets
];
}
module.exports = startMiddleware;