Skip to content

docs(files): document CORS_EXPOSED_HEADERS for TUS Directus-File-Id response header#639

Open
singhvishalkr wants to merge 1 commit intodirectus:mainfrom
singhvishalkr:docs-599-tus-directus-file-id-cors
Open

docs(files): document CORS_EXPOSED_HEADERS for TUS Directus-File-Id response header#639
singhvishalkr wants to merge 1 commit intodirectus:mainfrom
singhvishalkr:docs-599-tus-directus-file-id-cors

Conversation

@singhvishalkr
Copy link
Copy Markdown

@singhvishalkr singhvishalkr commented Apr 22, 2026

Fixes #599.

When a chunked (TUS) upload finishes, Directus returns the resulting file id in the Directus-File-Id response header rather than in the body. Browsers hide non-safelisted response headers across origins unless the server opts them in via Access-Control-Expose-Headers, so if the Data Studio or your app is on a different origin than the API, response.headers.get('Directus-File-Id') just returns null. The reporter on #599 said it took hours to realise that's what was going on, and @ComfortablyCoding asked for this to be documented rather than exposed by default.

The change is a single info callout at the end of the Chunked Uploads section in content/configuration/files.md. It names the header, explains why the browser hides it, shows the minimal CORS_EXPOSED_HEADERS="Directus-File-Id" value, and shows the comma-joined form Content-Range,Directus-File-Id so people already using the Content-Range default don't accidentally drop it.

I double-checked the link target /configuration/security-limits#cors still exists and that the existing default there is Content-Range, so the combined example is accurate.

  • Documentation Update
  • I have read the contribution guidelines.

…Id on TUS uploads

Fixes directus#599.

When a chunked upload finishes, Directus returns the file id in the
Directus-File-Id response header rather than in the body. Browsers drop
non-safelisted response headers across origins unless the server opts
them in via Access-Control-Expose-Headers, so when the app lives on a
different origin than the API the header is invisible to client JS.

Add an info callout under Chunked Uploads explaining the requirement
and showing how to add Directus-File-Id to CORS_EXPOSED_HEADERS
(including the comma-separated form that keeps the Content-Range
default intact).

Maintainer (ComfortablyCoding) explicitly asked for this to be
documented rather than exposed by default in the API.
@singhvishalkr singhvishalkr requested a review from a team as a code owner April 22, 2026 11:30
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 22, 2026

@singhvishalkr is attempting to deploy a commit to the Directus Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document Directus-File-Id header for TUS needs CORS_EXPOSED_HEADERS set for external domains

1 participant