Skip to content

Commit

Permalink
fix(historyApiFallback): fix router not work when historyfallback set…
Browse files Browse the repository at this point in the history
… to true (#27)

* refactor(router): add router priority constant

* fix(plugin): adjust priority of router and historyApiFallback
  • Loading branch information
xuchaoying authored Aug 5, 2019
1 parent a2d3fe5 commit e4f9c69
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/svrx/lib/constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ module.exports = {
PRIORITY: {
SERVE: 8,
DEFAULT: 10,
HISTORY_API_FALLBACK: 20,
HISTORY_API_FALLBACK: 11,
ROUTER: 12,
PROXY: 21,
MOCK: 30,
TRANSFORM: 100,
Expand Down
2 changes: 1 addition & 1 deletion packages/svrx/lib/plugin/svrx-plugin-serve/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ module.exports = {
const historyApiFallbackMiddleware = historyApiFallback(
historyApiFallbackOptions === true ? {} : historyApiFallbackOptions,
);
middleware.add('$serve-history-api-fallback', {
middleware.add('$history-api-fallback', {
priority: PRIORITY.HISTORY_API_FALLBACK,
onCreate: () => async (ctx, next) => {
if (ctx.status !== 404) {
Expand Down
3 changes: 2 additions & 1 deletion packages/svrx/lib/svrx.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const Injector = require('./injector');
const IO = require('./io');

const CONFIGS = require('./config-list');
const { PRIORITY } = require('./constant');
const getEvents = require('./shared/events');
const logger = require('./util/logger');

Expand Down Expand Up @@ -136,7 +137,7 @@ class Svrx {
.then(() => this.system.build())
.then(() => {
middleware.add('$router', {
priority: 10,
priority: PRIORITY.ROUTER,
onCreate: () => loader.middleware(),
});
if (typeof route === 'string') {
Expand Down

0 comments on commit e4f9c69

Please sign in to comment.