Skip to content

REST API returns 404 for filenames containing # (hash character) #15798

@andershermansen

Description

@andershermansen

Describe the Bug

When a file uploaded to Payload CMS has a # character in its filename, downloading it via the REST API returns a 404:

{"message":"Route not found \"/api/media/file/document #123.pdf\""}

Link to the code that reproduces this issue

pnpm dev directly in payload can use the repo steps

Reproduction Steps

  1. Upload a file with # in the filename (e.g., document #123.pdf)
  2. Try to access it via the admin panel
  3. Returns 404 instead of the file

Which area(s) are affected?

Not sure

Environment Info

Payload v3.78.0
Node v24.13.1
Next 16.2.0-canary.54

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions