Skip to content

API Route resolution conflict #3951

@timcosta

Description

@timcosta

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions