mirror of https://github.com/lissy93/dashy
✨ Implements router history mode, for cleaner URLs
This commit is contained in:
parent
f95b306157
commit
fffa2319c1
|
@ -12,6 +12,7 @@ const util = require('util');
|
||||||
const dns = require('dns');
|
const dns = require('dns');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
const bodyParser = require('body-parser');
|
const bodyParser = require('body-parser');
|
||||||
|
const history = require('connect-history-api-fallback');
|
||||||
|
|
||||||
/* Kick of some basic checks */
|
/* Kick of some basic checks */
|
||||||
require('./services/update-checker'); // Checks if there are any updates available, prints message
|
require('./services/update-checker'); // Checks if there are any updates available, prints message
|
||||||
|
@ -56,6 +57,7 @@ const method = (m, mw) => (req, res, next) => (req.method === m ? mw(req, res, n
|
||||||
|
|
||||||
try {
|
try {
|
||||||
connect()
|
connect()
|
||||||
|
.use(history())
|
||||||
.use(bodyParser.json())
|
.use(bodyParser.json())
|
||||||
// Serves up the main built application to the root
|
// Serves up the main built application to the root
|
||||||
.use(serveStatic(`${__dirname}/dist`))
|
.use(serveStatic(`${__dirname}/dist`))
|
||||||
|
|
|
@ -65,8 +65,12 @@ const makeMetaTags = (defaultTitle) => ({
|
||||||
metaTags: metaTagData,
|
metaTags: metaTagData,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* Routing mode, can be either 'hash', 'history' or 'abstract' */
|
||||||
|
const mode = 'history';
|
||||||
|
|
||||||
/* List of all routes, props, components and metadata */
|
/* List of all routes, props, components and metadata */
|
||||||
const router = new Router({
|
const router = new Router({
|
||||||
|
mode,
|
||||||
routes: [
|
routes: [
|
||||||
{ // The default view can be customized by the user
|
{ // The default view can be customized by the user
|
||||||
path: '/',
|
path: '/',
|
||||||
|
|
Loading…
Reference in New Issue