-
-
Notifications
You must be signed in to change notification settings - Fork 448
Open
Description
What version of Elysia is running?
What platform is your computer?
Darwin 25.1.0 arm64 arm
What environment are you using?
Bun 1.3.6
Are you using dynamic mode?
No, default aot: true. Issue also reproduces with aot: false.
What steps can reproduce the bug?
import { describe, expect, it } from 'bun:test'
import { Elysia } from 'elysia'
describe('Mount with prefix', () => {
it('mount without prefix - strips mount path', async () => {
const app = new Elysia()
.mount('/sdk/problems-domain', (request) => {
return Response.json({ path: new URL(request.url).pathname })
})
const response = await app
.handle(new Request('http://localhost/sdk/problems-domain/problems'))
.then((x) => x.json())
expect(response.path).toBe('/problems') // ✅ PASSES
})
it('mount with prefix - should strip both prefix and mount path', async () => {
const sdkApp = new Elysia({ prefix: '/sdk' })
.mount('/problems-domain', (request) => {
return Response.json({ path: new URL(request.url).pathname })
})
const app = new Elysia().use(sdkApp)
const response = await app
.handle(new Request('http://localhost/sdk/problems-domain/problems'))
.then((x) => x.json())
expect(response.path).toBe('/problems') // ❌ FAILS
})
})What is the expected behavior?
When using mount() on an Elysia instance that has a prefix option, the mounted handler should receive the URL with the full prefix + mount path stripped.
For request to /sdk/problems-domain/problems:
- Expected: handler receives path
/problems
What do you see instead?
The handler receives /main/problems - a mysterious /main/ prefix appears from nowhere.
without prefix: { path: "/problems" } ✅
with prefix: { path: "/main/problems" } ❌
Additional information
- The issue only occurs when combining
prefixoption withmount() - Using
mount()withoutprefixworks correctly - The
/main/string doesn't appear anywhere in my code
Have you tried removing the node_modules and bun.lockb?
Yes, issue persists with fresh install.
Metadata
Metadata
Assignees
Labels
No labels