Comments (4)
Closing this in favor of the mentioned issue.
from uppy.
Hi, you can also do this and not destroy the instance:
useEffect(() => {
uppy.getPlugin('XHRUpload').setOptions({
headers: {
Authorization: `Bearer ${token}`,
}
})
}, [token]);
The problem then is that it isn't retried. With tus you can do this:
import Uppy from '@uppy/core';
import Tus from '@uppy/tus';
new Uppy().use(Tus, {
endpoint: '',
async onBeforeRequest(req) {
const token = await getAuthToken();
req.setHeader('Authorization', `Bearer ${token}`);
},
onShouldRetry(err, retryAttempt, options, next) {
if (err?.originalResponse?.getStatus() === 401) {
return true;
}
return next(err);
},
async onAfterResponse(req, res) {
if (res.getStatus() === 401) {
await refreshAuthToken();
}
},
});
Ideally this would be consistent between uploaders.
from uppy.
yeah onBeforeRequest
is exactly what I had in mind. I'll try this one out for now, thanks
from uppy.
I just saw this in the codebase:
uppy/packages/@uppy/xhr-upload/src/index.ts
Lines 417 to 426 in 5004e84
So my useEffect
suggestion in #5042 (comment) should be sufficient for now.
from uppy.
Related Issues (20)
- Some thoughts about the UI of GooglePhotos.
- Done button shows when doneButtonHandler is null
- SyntaxError in Safari on macOS when loading uppy.min.js (v3.22.2 and later) HOT 3
- Please add documentation on how to use uppy with an existing s3 client HOT 1
- Tus endpoint not being respected after initial request behind reverse proxy HOT 9
- i18n "Shared with me" etc HOT 1
- Allow streaming upload also for unknown length streams HOT 1
- @uppy/companion: include origin in dynamic customer credentials
- Using Vue2 to integrate uppy caused a strange mistake HOT 2
- aws-nodejs-example | Multipart complete api | Throws 400 bad requests. HOT 5
- title.value is not accessible inside uppy.upload in vue
- I get this error "ResizeObserver loop completed with undelivered notifications" when I set width and height 100% in Angular HOT 5
- Uncaught TypeError: Cannot read properties of null (reading 'postMessage') in Companion's Callback Endpoint HOT 10
- Fix TypeScript sins HOT 1
- v4: typescript error for `uppy.setFileState()`
- Typescript error for 'new Uppy().use(AwsS3, {})' HOT 2
- XHR plugin expects upload response to be a valid JSON HOT 8
- companionAllowedHosts is not implemented in RemoteSources preset
- Uppy companion server error HOT 4
- Uppy 4.0.5 error HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uppy.