Skip to content

Next 15.4 API slug routes strip file extensions #81936

@tkmcmaster

Description

@tkmcmaster

Link to the code that reproduces this issue

https://github.com/tkmcmaster/api-slug-extension-bug/

To Reproduce

  1. Start the application (npm run dev)
  2. curl http://localhost:3000/api/json/abcd1234.json
{ sleep 5; curl http://localhost:3000/api/json/abcd1234.json; echo ; } & npm run dev

Response:
{"message":"method GET must have a json file","resultsFile":"abcd1234"}

Response in Next 15.3.x and lower:
{"message":"method GET has a json file: abcd1234.json","resultsFile":"abcd1234.json"}

Current vs. Expected behavior

In versions Next <=15.3.x the slug [resultsFile].ts will return whatever is passed. Starting in 15.4.0 through 15.4.2, any file extensions ('html' or 'json' at least) are stripped from the request.query parameters.

See branch https://github.com/tkmcmaster/api-slug-extension-bug/tree/next-15-3 that works currently.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Thu Jun  5 18:30:46 UTC 2025
  Available memory (MB): 15717
  Available CPU cores: 22
Binaries:
  Node: 22.16.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 15.4.2 // Latest available version is detected (15.4.2).
  eslint-config-next: N/A
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.8.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Route Handlers

Which stage(s) are affected? (Select all that apply)

next dev (local), next start (local)

Additional context

Checking canary releases, the first version that has the issue is 15.4.0-canary.45. Version 15.4.0-canary.44 did not reproduce the issue:

> [email protected] dev
> next dev --turbopack

   ▲ Next.js 15.4.0-canary.45 (Turbopack)
   - Local:        http://localhost:3000
   - Network:      http://10.255.255.254:3000

 ✓ Starting...
 ✓ Ready in 857ms
 ✓ Compiled /api/json/[resultsFile] in 97ms
resultsFile: abcd1234 { query: { resultsFile: 'abcd1234' } }
{"message":"method GET must have a json file","resultsFile":"abcd1234"} GET /api/json/abcd1234.json 400 in 41ms

Or canary 44:

> [email protected] dev
> next dev --turbopack

   ▲ Next.js 15.4.0-canary.44 (Turbopack)
   - Local:        http://localhost:3000
   - Network:      http://10.255.255.254:3000

 ✓ Starting...
 ✓ Ready in 815ms
 ✓ Compiled /api/json/[resultsFile] in 91ms
resultsFile: abcd1234.json { query: { resultsFile: 'abcd1234.json' } }
{"message":"method GET has a json file: abcd1234.json","resultsFile":"abcd1234.json"} GET /api/json/abcd1234.json 400 in 40ms

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions