Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
createExpressMiddleware,
skipRequireExtensions
} from 'create-react-server';
import app from '../src/app';
import template from './template';
try {
skipRequireExtensions();
const express = Express();
const port = process.env.PORT || 3000;
if (process.env.HOST_NAME) {
express.use(
forceDomain({
hostname: process.env.HOST_NAME,
protocol: process.env.FORCE_SSL === 'true' ? 'https' : 'http'
})
);
}
// NOTE: Currently this just redirects all former blog and dig posts to the new URL
// It will be a glorious day that we don't need this anymore...
express.get('*', (req, res, next) => {
if (req.path.indexOf('/blog') === -1 && req.path.indexOf('/digs') === -1) {
return next();
} else {
let params = req.path.split('/');
params = params.filter(n => n !== '' && n !== '[object%20Object]');
if (params.length === 1) {