I have a tusd dockerized as follows:
tusd-addressfull:
image: my-tusd
environment:
- FILE_SERVICE_URL
- AWS_ACCESS_KEY_ID=${S3_ACCESS_KEY}
- AWS_SECRET_ACCESS_KEY=${S3_SECRET_KEY}
- AWS_REGION=${S3_REGION}
- KEYCLOAK_URI
- KEYCLOAK_REALM
- TUSD_CLIENT_ID
- TUSD_CLIENT_SECRET
- TUSD_BUCKET=addressfull
- BASE_HOST
command: ["-s3-endpoint=${S3_ENDPONINT}", "-s3-bucket=addressfull", "-base-path=/files/addressfull"]
depends_on:
- file-service
And I would access it behind Spring Cloud Gateway, by:
#TUSD
- id: tusd-addressfull
uri: http://tusd-addressfull:1080
predicates:
- Path=/files/addressfull/**
filters:
- name: RequestSize
args:
maxSize: 2GB
The Spring Cloud Gateway accepts authenticated requests with Keycloak.
In my front-end example I'm using:
// Create a new tus upload
let upload = new tus.Upload(file, {
// endpoint: "https://mydomain/files/upload",
endpoint: "http://mydomain/files/addressfull",
headers: {
"Authorization": `Bearer ${keycloak.token}`,
},
retryDelays: [0, 3000, 5000, 10000, 20000],
metadata: {
filename: file.name,
filetype: file.type,
test: "test"
},
onError: function(error) {
console.log("Failed because: " + error)
},
onProgress: function(bytesUploaded, bytesTotal) {
let percentage = (bytesUploaded / bytesTotal * 100).toFixed(2)
console.log(bytesUploaded, bytesTotal, percentage + "%")
},
onSuccess: function() {
console.log("Download %s from %s", upload.file.name, upload.url)
}
})
But when I sent the upload request OPTIONS
pass with 200
but POST
method says 401 Unauthorized
and if I check the Authorization: Bearer TOKEN
header isn't present in POST
.
Seems as this issue.
Why?
What am I missing out?