New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tus: add onBeforeRequest
option
#2611
Conversation
@Acconut what do you think? |
It would be better if the uploadOptions.onBeforeRequest = (req) => {
const xhr = req.getUnderlyingObject()
xhr.withCredentials = !!opts.withCredentials
if (typeof uploadOptions.onBeforeRequest !== 'function') {
uploadOptions.onBeforeRequest(req)
}
} |
In this case, I was overwriting Maybe, it's related with this another issue?(#2443 ) |
I don't understand your last comment, to be honest. The code I posted above is not meant as a suggestion for how you can fix the issue in your application. It's a suggestion for how this PR should be implemented instead. |
Sorry, I got it wrong. I'll try your suggestion and update this PR. Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Let me know, if you made the changes, so I can review them, @bedgerotto!
@Acconut I checked out your suggestion and it didn't work because it is overwriting the But, based on this approach I have tested the following code and it works well once it is attached on the received uploadOptions.onBeforeRequest = (req) => {
const xhr = req.getUnderlyingObject()
xhr.withCredentials = !!opts.withCredentials
if (typeof opts.onBeforeRequest === 'function') {
opts.onBeforeRequest(req)
}
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A test would be nice but that's up to the Uppy team to decide. From a tus-js-client POV, this looks good 👍
onBeforeRequest
option
thank you! |
The onBeforeRequest callback cant be changed by Tus options after the changes on the issue #2518
In this case, I think that we could skip the default callback definition if the callbacck was passed through Tus options