Skip to content

Commit

Permalink
Unplugged the spa-base-path middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
peterhudec committed Feb 20, 2024
1 parent 449f7a0 commit 61c0941
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docs/Routing.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Routing

NOTE: Seems like none of this document is actually applied in Data Hub so we can remove it

## [React Router] & [Express]

Until we achieve the very unlikely state of the application where there would
Expand Down
4 changes: 2 additions & 2 deletions src/apps/dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const router = require('express').Router()

const urls = require('../../lib/urls')
const { renderDashboard } = require('./controllers')
const spaBasePath = require('../../middleware/spa-base-path')
// const spaBasePath = require('../../middleware/spa-base-path')

module.exports = {
router: router.get(
Expand All @@ -15,7 +15,7 @@ module.exports = {
urls.exportPipeline.index(),
urls.dashboard.myTasks(),
],
spaBasePath(urls.dashboard.index.route),
// spaBasePath(urls.dashboard.index.route),
renderDashboard
),
}
4 changes: 3 additions & 1 deletion src/client/provider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ const history = createBrowserHistory({
// The baseURI is set to the <base/> tag by the spaFallbackSpread
// middleware, which should be applied to each Express route where
// react-router is expected to be used.
basename: encodeURIComponent(new URL(document.baseURI).pathname),
// basename: encodeURIComponent(new URL(document.baseURI).pathname),
// basename: qs.stringify(new URL(document.baseURI).pathname),
// basename: new URL(document.baseURI).pathname,
})

const store = configureStore({
Expand Down
2 changes: 2 additions & 0 deletions src/middleware/spa-base-path.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO: Seems like this whole module lost its purpose and can be removed
const Layer = require('express/lib/router/layer')

const { NotFoundError } = require('./errors')
Expand All @@ -21,6 +22,7 @@ const { NotFoundError } = require('./errors')
* )
*/
module.exports = (path) => (req, res, next) => {
throw Error('AAAAAAAAAAAAAAAA')
const layer = new Layer(path + '*', {}, () => {})
if (layer.match(req.path)) {
// We need to remove the trailing part of the path configured in the express
Expand Down

0 comments on commit 61c0941

Please sign in to comment.