diff --git a/src/bundles/gateway.js b/src/bundles/gateway.js index 1e176d94e..73cb51bc3 100644 --- a/src/bundles/gateway.js +++ b/src/bundles/gateway.js @@ -34,7 +34,7 @@ export const checkValidHttpUrl = (value) => { } catch (_) { return false } - + console.log(`URL is valid: ${url}, url.protocol=${url.protocol}`) // lucas return url.protocol === 'http:' || url.protocol === 'https:' } @@ -97,7 +97,7 @@ async function expectSubdomainRedirect (url) { // but we seem to be able to access xhr.responseURL which is enough to see // if paths are redirected to subdomains. - const { redirected, url: responseUrl } = await fetch(url.toString()) + const { url: responseUrl } = await fetch(url.toString()) const { hostname } = new URL(responseUrl) if (!hostname.startsWith(IMG_HASH_1PX)) { @@ -145,7 +145,7 @@ export async function checkSubdomainGateway (gatewayUrl) { return true }) .catch((err) => { - console.log(err) + console.error(err) return false }) } diff --git a/src/components/public-subdomain-gateway-form/PublicSubdomainGatewayForm.js b/src/components/public-subdomain-gateway-form/PublicSubdomainGatewayForm.js index f8dfd956a..69d52c2fc 100644 --- a/src/components/public-subdomain-gateway-form/PublicSubdomainGatewayForm.js +++ b/src/components/public-subdomain-gateway-form/PublicSubdomainGatewayForm.js @@ -9,11 +9,19 @@ const PublicSubdomainGatewayForm = ({ t, doUpdatePublicSubdomainGateway, publicS const initialIsValidGatewayUrl = !checkValidHttpUrl(value) const [isValidGatewayUrl, setIsValidGatewayUrl] = useState(initialIsValidGatewayUrl) - // Updates the border of the input to indicate validity useEffect(() => { - const isValid = checkSubdomainGateway(value) - setIsValidGatewayUrl(isValid) + const validateUrl = async () => { + try { + const isValid = await checkSubdomainGateway(value) + setIsValidGatewayUrl(isValid) + } catch (error) { + console.error('Error checking subdomain gateway:', error) + setIsValidGatewayUrl(false) + } + } + + validateUrl() }, [value]) const onChange = (event) => setValue(event.target.value)