diff --git a/Common/UI/Components/Captcha/Captcha.tsx b/Common/UI/Components/Captcha/Captcha.tsx index 814ef790b7..aea5040f3e 100644 --- a/Common/UI/Components/Captcha/Captcha.tsx +++ b/Common/UI/Components/Captcha/Captcha.tsx @@ -19,15 +19,15 @@ const Captcha: React.FC = ({ className, }: CaptchaProps): JSX.Element => { const captchaRef = React.useRef(null); + const onTokenChangeRef = React.useRef(onTokenChange); - const handleTokenChange = React.useCallback( - (token: string | null) => { - if (onTokenChange) { - onTokenChange(token || ""); - } - }, - [onTokenChange], - ); + React.useEffect(() => { + onTokenChangeRef.current = onTokenChange; + }, [onTokenChange]); + + const handleTokenChange = React.useCallback((token: string | null) => { + onTokenChangeRef.current?.(token || ""); + }, []); React.useEffect(() => { captchaRef.current?.resetCaptcha(); diff --git a/Home/Static/.well-known/assetlinks.json b/Home/Static/.well-known/assetlinks.json new file mode 100644 index 0000000000..97b95f9948 --- /dev/null +++ b/Home/Static/.well-known/assetlinks.json @@ -0,0 +1,8 @@ +[{ + "relation": ["delegate_permission/common.handle_all_urls"], + "target": { + "namespace": "android_app", + "package_name": "com.oneuptime.twa", + "sha256_cert_fingerprints": ["54:96:AD:87:CD:1E:61:66:A3:7A:C4:34:89:84:8E:90:2A:64:FA:A9:33:EB:F6:08:1E:09:48:19:D7:A1:79:70"] + } + }] diff --git a/Nginx/default.conf.template b/Nginx/default.conf.template index f09197ea7e..14412a21cb 100644 --- a/Nginx/default.conf.template +++ b/Nginx/default.conf.template @@ -380,6 +380,22 @@ ${PROVISION_SSL_CERTIFICATE_KEY_DIRECTIVE} proxy_pass http://app/api/acme-challenge/.well-known; } + location /.well-known/assetlinks.json { + # This is for nginx not to crash when service is not available. + resolver 127.0.0.1 valid=30s; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + # enable WebSockets (for ws://sockjs not connected error in the accounts source: https://stackoverflow.com/questions/41381444/websocket-connection-failed-error-during-websocket-handshake-unexpected-respon) + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + + proxy_pass http://home/public/assets/.well-known/assetlinks.json; + } + # PWA manifest and service worker with proper headers for home location ~* ^/(manifest\.json|service-worker\.js)$ { resolver 127.0.0.1 valid=30s;