diff --git a/packages/@uppy/companion/src/companion.js b/packages/@uppy/companion/src/companion.js index aeb642d91c..a3d6235de9 100644 --- a/packages/@uppy/companion/src/companion.js +++ b/packages/@uppy/companion/src/companion.js @@ -115,7 +115,7 @@ module.exports.app = (optionsArg = {}) => { // add uppy options to the request object so it can be accessed by subsequent handlers. app.use('*', middlewares.getCompanionMiddleware(options)) app.use('/s3', s3(options.s3)) - app.use('/url', url()) + if (options.enableUrlEndpoint) app.use('/url', url()) app.post('/:providerName/preauth', express.json(), express.urlencoded({ extended: false }), middlewares.hasSessionAndProvider, middlewares.hasBody, middlewares.hasOAuthProvider, controllers.preauth) app.get('/:providerName/connect', middlewares.hasSessionAndProvider, middlewares.hasOAuthProvider, controllers.connect) diff --git a/packages/@uppy/companion/src/config/companion.js b/packages/@uppy/companion/src/config/companion.js index c9eddb47cd..59c4f0c991 100644 --- a/packages/@uppy/companion/src/config/companion.js +++ b/packages/@uppy/companion/src/config/companion.js @@ -16,6 +16,7 @@ const defaultOptions = { getKey: defaultGetKey, expires: 800, // seconds }, + enableUrlEndpoint: true, // todo next major make this default false allowLocalUrls: false, logClientVersion: true, periodicPingUrls: [], diff --git a/packages/@uppy/companion/src/server/controllers/s3.js b/packages/@uppy/companion/src/server/controllers/s3.js index 4d1c146b5b..9eaac4e91c 100644 --- a/packages/@uppy/companion/src/server/controllers/s3.js +++ b/packages/@uppy/companion/src/server/controllers/s3.js @@ -441,6 +441,10 @@ module.exports = function s3 (config) { }, next) } + if (config.bucket == null) { + return express.Router() // empty router because s3 is not enabled + } + return express.Router() .get('/sts', getTemporarySecurityCredentials) .get('/params', getUploadParameters) diff --git a/packages/@uppy/companion/src/standalone/helper.js b/packages/@uppy/companion/src/standalone/helper.js index f1ce3dbfe7..5f84608266 100644 --- a/packages/@uppy/companion/src/standalone/helper.js +++ b/packages/@uppy/companion/src/standalone/helper.js @@ -136,6 +136,8 @@ const getConfigFromEnv = () => { oauthDomain: process.env.COMPANION_OAUTH_DOMAIN, validHosts, }, + // todo next major make this default false + enableUrlEndpoint: process.env.COMPANION_ENABLE_URL_ENDPOINT == null || process.env.COMPANION_ENABLE_URL_ENDPOINT === 'true', periodicPingUrls: process.env.COMPANION_PERIODIC_PING_URLS ? process.env.COMPANION_PERIODIC_PING_URLS.split(',') : [], periodicPingInterval: process.env.COMPANION_PERIODIC_PING_INTERVAL ? parseInt(process.env.COMPANION_PERIODIC_PING_INTERVAL, 10) : undefined,