Skip to content

Commit

Permalink
fix(status): add trailing slash
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Mar 21, 2021
1 parent 939c3bc commit f2b6e67
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/plugin-status/server/webui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export function apply(ctx: Context, config: Config = {}) {
const [vite] = await Promise.all([createVite(), createAdapter()])

ctx.router.get(uiPath + '(/.+)*', async (koa) => {
// add trailing slash and redirect
if (koa.path === uiPath && !uiPath.endsWith('/')) {
return koa.redirect(koa.path + '/')
}
const filename = resolve(root, koa.path.slice(uiPath.length).replace(/^\/+/, ''))
if (!filename.startsWith(root) && !filename.includes('node_modules')) {
return koa.status = 403
Expand Down

0 comments on commit f2b6e67

Please sign in to comment.