Default route(404) is now Content-Type aware(json)
- Cleanup
This commit is contained in:
parent
9c4eb3200e
commit
b1a73ebd4a
@ -44,7 +44,6 @@ export const prisma = new PrismaClient({
|
|||||||
|
|
||||||
export const app = express();
|
export const app = express();
|
||||||
app.set('x-powered-by', false);
|
app.set('x-powered-by', false);
|
||||||
//app.set('strict routing', true);
|
|
||||||
app.engine('html', eta.renderFile);
|
app.engine('html', eta.renderFile);
|
||||||
|
|
||||||
// app.use(cors());
|
// app.use(cors());
|
||||||
@ -54,10 +53,8 @@ app.use(bodyParser.urlencoded({ extended: false }));
|
|||||||
app.use(bodyParser.json());
|
app.use(bodyParser.json());
|
||||||
|
|
||||||
app.use(fileUpload());
|
app.use(fileUpload());
|
||||||
// Configure static https://expressjs.com/de/starter/static-files.html
|
|
||||||
// app.use('/static', express.static('public'));
|
|
||||||
|
|
||||||
app.use(express.static(__path + '/static'));
|
app.use(express.static(__path + '/static'));
|
||||||
|
|
||||||
app.use(routes);
|
app.use(routes);
|
||||||
|
|
||||||
app.listen(config.global.http_port, config.global.http_listen_address, () => {
|
app.listen(config.global.http_port, config.global.http_listen_address, () => {
|
||||||
|
@ -13,9 +13,13 @@ Router.use('/api', api_routes);
|
|||||||
Router.use('/', frontend_routes);
|
Router.use('/', frontend_routes);
|
||||||
|
|
||||||
// Default route.
|
// Default route.
|
||||||
Router.get('*', function (req, res) {
|
Router.all('*', function (req, res) {
|
||||||
// TODO: Respond based on content-type (with req.is('application/json'))
|
// TODO: Respond based on content-type (with req.is('application/json'))
|
||||||
|
if (req.is('application/json')) {
|
||||||
|
res.status(404).json({ errorcode: '404' });
|
||||||
|
} else {
|
||||||
res.status(404).render(__path + '/src/frontend/errors/404.eta.html', { url: req.originalUrl });
|
res.status(404).render(__path + '/src/frontend/errors/404.eta.html', { url: req.originalUrl });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default Router;
|
export default Router;
|
||||||
|
Loading…
Reference in New Issue
Block a user