dynamic react router
This commit is contained in:
@@ -29,7 +29,6 @@ DB.sync().then(()=>{
|
||||
api.use(bodyParser.json());
|
||||
api.use(bodyParser.urlencoded({ extended: false }));
|
||||
|
||||
|
||||
api.listen(API_PORT, () => {
|
||||
console.log(`API is now running on http://localhost:${API_PORT}`);
|
||||
});
|
||||
@@ -74,7 +73,7 @@ app.use(assets({
|
||||
paths: ["./../node_modules"],
|
||||
build: true,
|
||||
buildDir: false,
|
||||
//compile: false,
|
||||
// compile: false,
|
||||
compress: true
|
||||
}));
|
||||
// serve public static files.
|
||||
@@ -83,44 +82,10 @@ dev_server.app.use('/', express.static(path.resolve(__dirname, 'public')));
|
||||
// view engine set up
|
||||
app.set('views', path.join(__dirname, 'views'));
|
||||
app.set('view engine', 'jade');
|
||||
app.get("/", (req, res, next)=>{
|
||||
app.get("*", (req, res, next)=>{
|
||||
res.render("index");
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
* Handle Errors
|
||||
*/
|
||||
|
||||
// catch 404 and forward to error handler
|
||||
app.use(function(req, res, next) {
|
||||
var err = new Error('Not Found');
|
||||
err.status = 404;
|
||||
next(err);
|
||||
});
|
||||
|
||||
// development error handler
|
||||
// will print stacktrace
|
||||
if (app.get('env') === 'development') {
|
||||
app.use(function(err, req, res, next) {
|
||||
res.status(err.status || 500);
|
||||
res.render('error', {
|
||||
message: err.message,
|
||||
error: err
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// production error handler
|
||||
// no stacktraces leaked to user
|
||||
app.use(function(err, req, res, next) {
|
||||
res.status(err.status || 500);
|
||||
res.render('error', {
|
||||
message: err.message,
|
||||
error: {}
|
||||
});
|
||||
});
|
||||
|
||||
dev_server.listen(APP_PORT, () => {
|
||||
console.log(`App is now running on http://localhost:${APP_PORT}`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user