Application crashing after adding disableDotRule: true
nighojkarv opened this issue · 5 comments
After adding disableDotRule:true the entire application is crashing.
Console error: Uncaught SyntaxError: Unexpected token <
The application works without issues when disableDotRule is false or absent.
This is my dev-server.js
import express from 'express';
import morgan from 'morgan';
import history from 'connect-history-api-fallback';
import proxy from 'http-proxy-middleware';
import bodyParser from 'body-parser';
import webpack from 'webpack';
import webpackDevMiddleware from 'webpack-dev-middleware';
import webpackHotMiddleware from 'webpack-hot-middleware';
import webpackConfig from '../webpack.config';
import api from '../src/test/api/api';
const app = express();
app.use(morgan('dev'));
const compiler = webpack(webpackConfig);
app.use(history({
index: '/index.html',
disableDotRule: true,
}));
app.use(webpackDevMiddleware(compiler, {
noInfo: true,
publicPath: webpackConfig.output.publicPath,
stats: {
colors: true,
},
}));
app.use(webpackHotMiddleware(compiler, {
log: console.log, // eslint-disable-line no-console
}));
// set up proxy
try {
const proxySettings = require('./proxySettings.default'); // eslint-disable-line global-require, import/no-unresolved
Object.entries(proxySettings).forEach((entry) => {
const [contextPath, proxyConfig] = entry;
app.use(contextPath, proxy(Object.assign({}, proxyConfig, {
onProxyRes: (proxyRes) => {
const setCookie = proxyRes.headers['set-cookie'];
if (setCookie) {
// eslint-disable-next-line no-param-reassign
proxyRes.headers['set-cookie'] = setCookie.map((cookie) => cookie.replace(/; Secure/, ''));
}
},
})));
});
} catch (e) {
if (!e.message || e.message !== "Cannot find module './proxySettings'") {
console.error(e); // eslint-disable-line no-console
}
}
// set up mock api
app.use(bodyParser.json());
api.defineApi(app);
// start express server
const listener = app.listen(8181, () => {
const address = listener.address();
// eslint-disable-next-line no-console
console.log(`Dev server listening on ${address.address}:${address.port}`);
});
This error is most likely not related to connect-history-api-fallback
, but rather your application. Could you please post the full stacktrace?
I am not getting any other error on the stack trace. Just that one error.
I will have to close this issue. This is most likely not an issue in this library. I'd recommend to ask for help on Stackoverflow as I have no capacity to handle this.
I have the same error and it comes whenever i add the disableDotRule:true
i was able to trace the error and in comes from app.js auto generated from index.html
<!DOCTYPE html>
...