-
Notifications
You must be signed in to change notification settings - Fork 2k
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
@uppy/aws-s3-multipart: setting companionHeaders
in pre-processor fails first upload
#4262
Comments
Speaking of setting the headers. I also looked at #3770 but I did not understand it What is the right way to achieve what I do in the |
Am I understanding correctly that you don't experience problems if you also set |
Sorry if I expressed myself poorly. Yes, when set initially, the upload works fine right away |
Alright good. I still expected that only the pre-processor should have been enough so something might be going wrong indeed. |
companionHeaders
in pre-processor fails first upload
I am running into a similar issue where the companion headers are not being sent to my custom companion endpoints. In my case I need a CSRF header to be sent along with the request. Here's how I configure the multipart plugin:
Unfortunately, the X-CSRFToken I provide is not included in the request headers. If I manually patch the post method of the companion client and concatenate the base headers with the companion headers, this works and the header is forwarded along with the request. That is, changing
to
But I am not sure if this is sufficient for all users or if I'm even using the companion headers correctly. I am happy to help on this fix, as I'm currently having to run on a fork until I can find a way to get these headers passed to my companion endpoint. |
Hi @aarongundel, if you would be willing to provide a PR that would be great! Take a look at this PR, which seems very relevant to problem/fix: #3770 |
What is the status on this? The workaround mentioned here is not very reliable. The idea is to refresh the token just before uploading so we don't start the upload with an expired token. When setting the Using just the preprocessor, the first upload always fails, after which it succeeds on retry. The preprocessor executes and updates the options correctly, but in the initial |
I had a theory that this could be related to the implementation of the
which is registered as a preprocessor:
According to the docs, I made a simple test case resembling the situation described in this issue which would indeed fail, and then altered the setOptions method to also call
The test now does succeed, making me hopeful that this could indeed work... The only issue is that I've never worked with a monorepo like this before and I'm having a really hard time getting yarn to use my fork... I will submit an MR anyways so you can have a look and maybe test it out. EDIT: see #4687 |
I'm using the latest version of Uppy and I'm still getting the same issue.
The request doesn't include the Authorization token. |
Did you call addPreProcessor like so?
|
Just tried that without success. The request still doesn't include the header. |
I have no idea then, we are using it without any issues:) |
I changed to aws-s3-multipart to try your solution:
However here are the request headers:
As you can see "Authorization" is still not being included... Uppy versions:
|
I created a separate issue as this is not really related to addPreprocessor: #4807 |
Initial checklist
Link to runnable example
No response
Steps to reproduce
I am trying to upgrade to uppy v2 to v3 and now it fails to upload to out s3 multipart endpoint
We used the following code to set auth header right before uploading
Now the header is not being sent. I found the related issue #2465 but there appears to be more to it
I see the
OPTIONS
preflight request and it does come back with the expected headersStill,
Authorization
is not included in thePOST
.Expected behavior
Authorization header should be sent
Actual behavior
Authorization header is sent only on the second upload attempt
Thus, I compared the preflight between the:
+access-control-request-headers: authorization,content-type
No
access-control-request-headers
is present on theOPTIONS
when upload fails. This may be a red herring but I found that setting the companion headers in the initial plugin setup mitigates the problemuppy.use(AwsS3Multipart, { companionUrl: uploadURL, + companionHeaders: prepareHeaders(uploadURL, this.$store) })
The text was updated successfully, but these errors were encountered: