Skip to content

Commit

Permalink
@uppy/companion: make allowLocalUrls and providerOptions available to…
Browse files Browse the repository at this point in the history
… providers
  • Loading branch information
dschmidt committed Jul 9, 2023
1 parent d9f4df4 commit 72e7443
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions packages/@uppy/companion/src/server/provider/Provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
class Provider {
/**
*
* @param {object} options
* @param {{providerName: string, allowLocalUrls: boolean, providerOptions: object}} options
*/
constructor (options) { // eslint-disable-line no-unused-vars
constructor ({ allowLocalUrls, providerOptions }) {
// Some providers might need cookie auth for the thumbnails fetched via companion
this.needsCookieAuth = false
this.allowLocalUrls = allowLocalUrls
this.providerOptions = providerOptions
return this
}

Expand Down
4 changes: 3 additions & 1 deletion packages/@uppy/companion/src/server/provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ module.exports.getProviderMiddleware = (providers) => {
const middleware = (req, res, next, providerName) => {
const ProviderClass = providers[providerName]
if (ProviderClass && validOptions(req.companion.options)) {
req.companion.provider = new ProviderClass({ providerName })
const providerOptions = req.companion.options.providerOptions[providerName] || {}
const { allowLocalUrls } = req.companion.options
req.companion.provider = new ProviderClass({ providerName, providerOptions, allowLocalUrls })
req.companion.providerClass = ProviderClass

if (isOAuthProvider(ProviderClass.authProvider)) {
Expand Down

0 comments on commit 72e7443

Please sign in to comment.