tus / tusd

Reference server implementation in Go of tus: the open protocol for resumable file uploads
https://tus.github.io/tusd
MIT License
3.04k stars 475 forks source link

Exposing header via cors-expose-header Issue #1059

Closed xoraingroup closed 8 months ago

xoraingroup commented 9 months ago

Question I have tried to expose x-token using -cors-allow-headers x-token -cors-expose-headers x-token , but I am not able to get it in pre-flight response header.

image

Tried all possible combinations and used following branches and tags

main branch v2.2.0 v2.2.1

I am not able to get those headers. Am I doing it all wrong? Please help. Thank you

Setup details Please provide following details, if applicable to your situation:

Linux

Last commit of the main branch is

commit e2784199a268bd03cdc188f376386fadc6735582 (HEAD -> main, origin/main, origin/HEAD)
Author: Martin Stemmle <martnst@users.noreply.github.com>
Date:   Wed Dec 20 09:14:28 2023 +0100

    docs: Unify style of CLI arguments (#1050)

    Update CLI option examples from 2 leading dashes to just 1.
Acconut commented 8 months ago
  • For some weird reason it shows NA

The version is only available if you use the pre-built binaries. If you compile it on your own, no version information is embedded in the output. If you were using the pre-built binary and still didn't, get any version details, you might be running into the bug reported in https://github.com/tus/tusd/issues/1045 and fixed in the latest v2.2.1 release.

I am not able to get those headers. Am I doing it all wrong? Please help. Thank you

I am not able to reproduce this. Running tusd via tusd -cors-allow-headers x-token -cors-expose-headers x-token, the response from curl incluses the header:

~ $ curl -X OPTIONS -i http://[::]:8080/files/ -H "Origin: example.com"
HTTP/1.1 200 OK
Access-Control-Allow-Headers: Authorization, Origin, X-Requested-With, X-Request-ID, X-HTTP-Method-Override, Content-Type, Upload-Length, Upload-Offset, Tus-Resumable, Upload-Metadata, Upload-Defer-Length, Upload-Concat, Upload-Complete, Upload-Draft-Interop-Version, x-token
Access-Control-Allow-Methods: POST, HEAD, PATCH, OPTIONS, GET, DELETE
Access-Control-Allow-Origin: example.com
Access-Control-Max-Age: 86400
Tus-Extension: creation,creation-with-upload,termination,concatenation,creation-defer-length
Tus-Resumable: 1.0.0
Tus-Version: 1.0.0
Vary: Origin
X-Content-Type-Options: nosniff
Date: Mon, 08 Jan 2024 14:18:12 GMT
Content-Length: 0

In Firefox, I can also see the value in the preflight response:

image

Acconut commented 8 months ago

I am closing this since I assume that the question has been answered. Feel free to continue here if that's not the case.