Skip to content

strictPath is forced to true when aot: false is set #1458

@Chipsnet

Description

@Chipsnet

What version of Elysia is running?

[email protected]

What platform is your computer?

Darwin 24.6.0 arm64 arm

What environment are you using

Bun 1.2.20

Are you using dynamic mode?

Yes

What steps can reproduce the bug?

Set aot: false like this:

import { Elysia } from "elysia";

const app = new Elysia({
  aot: false,
})
  .get("/", () => "Hello Elysia")
  .get("/ping", () => "pong")
  .group("/api", (app) =>
    app.get("/", () => "Hello Elysia").get("/ping", () => "pong"),
  )
  .listen(3000);

console.log(
  `🦊 Elysia is running at ${app.server?.hostname}:${app.server?.port}`,
);

Then send GET requests to the following URLs:

http://localhost:3000/
http://localhost:3000/ping
http://localhost:3000/ping/
http://localhost:3000/api
http://localhost:3000/api/
http://localhost:3000/api/ping
http://localhost:3000/api/ping/

✅: 200 / ❌: 404

What is the expected behavior?

When aot: false is set and strictPath is not specified (thus defaulting to false),
the following requests should succeed:

http://localhost:3000/ping/
http://localhost:3000/api
http://localhost:3000/api/ping/

In other words, the behavior should match the default strictPath: false mode,
where both paths—with and without trailing slashes—are treated as equivalent.

What do you see instead?

The routes behave as if strictPath: true were enabled,
even though it is not explicitly set.

  • Paths with trailing slashes (e.g., /ping/, /api/ping/) return 404 Not Found.
  • Paths without trailing slashes (e.g., /ping, /api/ping) work correctly.
  • The same behavior occurs for nested routes under .group() as well.

If strictPath is explicitly set to false, it works correctly as expected.
However, strictPath defaults to false, and this issue only occurs when aot: false is set.
When aot is not set (default: true), routing behaves correctly with strictPath: false.

So, setting aot: false seems to unintentionally make the app behave as if strictPath were true.

Additional information

No response

Have you try removing the node_modules and bun.lockb and try again yet?

yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions