Skip to content

Commit

Permalink
fix: auto redirect when using old paths (#3308)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando authored Sep 29, 2023
1 parent 8b770e9 commit e5793bd
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,27 @@ app.use(
})
)

// fix back compatibility with old history mode after switching to hash mode
const redirectPaths = [
'/control-panel',
'/smart-start',
'/settings',
'/scenes',
'/debug',
'/store',
'/mesh',
]
app.use('/', (req, res, next) => {
if (redirectPaths.includes(req.originalUrl)) {
// get path when running behind a proxy
const path = req.header('X-External-Path').replace(/\/$/, '')

res.redirect(`${path}/#${req.originalUrl}`)
} else {
next()
}
})

app.use('/', express.static(utils.joinPath(false, 'dist')))

app.use(cors({ credentials: true, origin: true }))
Expand Down

0 comments on commit e5793bd

Please sign in to comment.