Hi All,
I’m using the Uppy Dropbox plugin combined with Companion stand alone server.
I’m able to login into Dropbox account and upload files from there thanks to the compaion, but…
i’m trying hard to pass in each Companion call a custom header without success.
Here is my code:
uppy.use(Dropbox, {
target: document.getElementById(“domElementID”),
companionUrl: “url to companion”,
serverHeaders: {
test: ‘custom header’
},
companionHeaders:{
test: ‘custom header’
}
})
I tried to use even serverHeaders key or companionHeaders key… but when i check the network request on the browser inspector or i log headers from companion (req.headers), there isn’t my defined custom header…
Is this a bug, or i’m missing something?
Please help
Thanks!
This seems like a strange issue. Looking through the source code, here is the code that sets the headers:
get defaultHeaders () {
return {
Accept: 'application/json',
'Content-Type': 'application/json',
'Uppy-Versions': `@uppy/companion-client=${RequestClient.VERSION}`
}
}
headers () {
const userHeaders = this.opts.companionHeaders || this.opts.serverHeaders || {}
return Promise.resolve({
...this.defaultHeaders,
...userHeaders
})
}
I can’t identify the exact issue, but I have a few questions that might help:
- Are the default headers sent?
- Is this specific to the Dropbox plugin or does it apply to all plugins?
I’ll continue looking through the code and see if i can find an answer to this. For now though, I am not totally sure what the problem is
- Andrew
1 Like
Did you ever find a solution? I’m running into the same issue using AwsS3Multipart
.use(AwsS3Multipart, {
limit: 6,
companionUrl: 'http://localhost:5000',
companionHeaders: {
Authorization: 'Bearer my_token_here',
'X-My-Cool-Header': 'Tacos for dinner? Yes please!'
},
})
I’m looking in my browser tools network requests tab and I’m not seeing Authorization, X-My-Cool-Header, or Uppy-Versions in the POST request.
Edit found the solution here (It was a CORS misconfiguration.) Today I learned that the browser won’t send headers it doesn’t have permission to send.