From c5494ee3c2e042ed6a80d2d49f2da32b7562cf7d Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Sun, 4 Jun 2023 23:20:15 +0200 Subject: [PATCH] fix undefined protocol and example page fixes #4478 --- packages/@uppy/companion/src/standalone/helper.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/@uppy/companion/src/standalone/helper.js b/packages/@uppy/companion/src/standalone/helper.js index 3e95b1fc8e..a5d0428819 100644 --- a/packages/@uppy/companion/src/standalone/helper.js +++ b/packages/@uppy/companion/src/standalone/helper.js @@ -41,11 +41,13 @@ const hasProtocol = (url) => { return url.startsWith('https://') || url.startsWith('http://') } +const companionProtocol = process.env.COMPANION_PROTOCOL || 'http' + function getCorsOrigins () { if (process.env.COMPANION_CLIENT_ORIGINS) { return process.env.COMPANION_CLIENT_ORIGINS .split(',') - .map((url) => (hasProtocol(url) ? url : `${process.env.COMPANION_PROTOCOL || 'http'}://${url}`)) + .map((url) => (hasProtocol(url) ? url : `${companionProtocol}://${url}`)) } if (process.env.COMPANION_CLIENT_ORIGINS_REGEX) { return new RegExp(process.env.COMPANION_CLIENT_ORIGINS_REGEX) @@ -128,7 +130,7 @@ const getConfigFromEnv = () => { }, server: { host: process.env.COMPANION_DOMAIN, - protocol: process.env.COMPANION_PROTOCOL, + protocol: companionProtocol, path: process.env.COMPANION_PATH, implicitPath: process.env.COMPANION_IMPLICIT_PATH, oauthDomain: process.env.COMPANION_OAUTH_DOMAIN, @@ -213,7 +215,7 @@ exports.buildHelpfulStartupMessage = (companionOptions) => { const buildURL = utils.getURLBuilder(companionOptions) const callbackURLs = [] Object.keys(companionOptions.providerOptions).forEach((providerName) => { - callbackURLs.push(buildURL(`/connect/${providerName}/redirect`, true)) + callbackURLs.push(buildURL(`/${providerName}/redirect`, true)) }) return stripIndent` @@ -227,7 +229,8 @@ exports.buildHelpfulStartupMessage = (companionOptions) => { While you did an awesome job on getting Companion running, this is just the welcome message, so let's talk about the places that really matter: - - Be sure to add ${callbackURLs.join(', ')} as your Oauth redirect uris on their corresponding developer interfaces. + - Be sure to add the following URLs as your Oauth redirect uris on their corresponding developer interfaces: + ${callbackURLs.join(', ')} - The URL ${buildURL('/metrics', true)} is available for statistics to keep Companion running smoothly - https://github.com/transloadit/uppy/issues - report your bugs here