router icon indicating copy to clipboard operation
router copied to clipboard

API Route resolution conflict

Open timcosta opened this issue 9 months ago • 1 comments

Which project does this relate to?

Start

Describe the bug

API Route precedence isn't working correctly when using two files in a directory such as

  • resource/$resourceId.ts - implements a GET method
  • resource/batch.ts - implements a POST method that takes a payload with a list of resource ids to fetch in bulk.

When you call POST /resource/batch you get back a 405 method not allowed error instead of the expected 200.

Your Example Website or App

None, discussed in discord

Steps to Reproduce the Bug or Issue

  1. Add route using createAPIFileRoute at /resource/$resourceId.ts with a GET handler.
  2. Add route using createAPIFileRoute at /resource/batch.ts with a POST handler.
  3. Call POST /resource/batch and get back a 405.

Expected behavior

I should get back a 200 because POST /resource/batch exactly matches a defined route which should take precedence over a parameterized route.

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Chrome and curl
  • Version: v133

Additional context

I'm submitting this bug report after a conversation with Manuel in the Discord #start channel today, where he helped me figure out why i was getting a 405 method not allowed when calling an endpoint that was defined.

timcosta avatar Apr 06 '25 19:04 timcosta

this should be fixed now with server routes. can you please check?

schiller-manuel avatar Jun 13 '25 19:06 schiller-manuel