Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global catch-all route does not work #18131

Closed
macieklamberski opened this issue Mar 12, 2025 · 0 comments · Fixed by #18148
Closed

Global catch-all route does not work #18131

macieklamberski opened this issue Mar 12, 2025 · 0 comments · Fixed by #18148
Labels
bug Something isn't working bun:serve Bun.serve and HTTP server

Comments

@macieklamberski
Copy link

macieklamberski commented Mar 12, 2025

What version of Bun is running?

1.2.5+013fdddc6

What platform is your computer?

Darwin 24.3.0 arm64 arm

What steps can reproduce the bug?

  1. Create example1.ts file with the below content:

    import { serve } from 'bun'
    
    serve({
      routes: {
        '/*': new Response('Global catch-all'),
      },
    })
  2. Create example2.ts file with the below content:

    import { serve } from 'bun'
    
    serve({
      routes: {
        '/*': () => new Response('Global catch-all'),
      },
    })
  3. Run both examples to see the different behavior.

    bun example1.ts # And open http://localhost:3000
    bun example2.ts # And open http://localhost:3000

What is the expected behavior?

Both examples should work the same — when I enter the root page, I should see the "Global catch-all" text.

What do you see instead?

Currently, this only works with static responses (example 1), even though shows that the second variant with the route handler function is also valid. See point 4. here: https://bun.sh/docs/api/http#route-precedence.

Additional information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working bun:serve Bun.serve and HTTP server
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants