@@ -37,16 +37,18 @@ export function AddToAppButton() {
3737 console . log ( 'PWA: hasBeforeInstallPrompt =' , 'onbeforeinstallprompt' in window )
3838 console . log ( 'PWA: hostname =' , window . location . hostname )
3939
40- // For localhost development : if no beforeinstallprompt after 2 seconds,
41- // assume it's available for testing (but only on localhost)
40+ // For development localhost OR production HTTPS : if no beforeinstallprompt after 2 seconds,
41+ // assume it's available for testing/installation
4242 const isLocalhost = window . location . hostname === 'localhost' || window . location . hostname === '127.0.0.1'
4343 const isDev = process . env . NODE_ENV === 'development'
44+ const isHTTPS = window . location . protocol === 'https:'
45+ const isProductionDomain = ! isLocalhost && isHTTPS
4446
4547 let timeoutId : NodeJS . Timeout | null = null
46- if ( isDev && isLocalhost ) {
48+ if ( ( isDev && isLocalhost ) || isProductionDomain ) {
4749 timeoutId = setTimeout ( ( ) => {
4850 if ( ! isInstallable && ! isIOS ( ) ) {
49- console . log ( 'PWA: No beforeinstallprompt after 2s, enabling for localhost testing ' )
51+ console . log ( 'PWA: No beforeinstallprompt after 2s, enabling for production/ localhost' )
5052 setIsInstallable ( true )
5153 }
5254 } , 2000 )
@@ -99,17 +101,21 @@ export function AddToAppButton() {
99101 // Show button if:
100102 // 1. Actually installable (beforeinstallprompt fired), OR
101103 // 2. iOS device (can always install via Safari), OR
102- // 3. Development mode AND localhost (for testing)
104+ // 3. Development mode AND localhost (for testing), OR
105+ // 4. Production domain with HTTPS (assume PWA is available)
103106 const isLocalhost = window . location . hostname === 'localhost' || window . location . hostname === '127.0.0.1'
104107 const isDev = process . env . NODE_ENV === 'development'
105- const shouldShowButton = isInstallable || isIOS ( ) || ( isDev && isLocalhost )
108+ const isHTTPS = window . location . protocol === 'https:'
109+ const isProductionDomain = ! isLocalhost && isHTTPS
110+
111+ const shouldShowButton = isInstallable || isIOS ( ) || ( isDev && isLocalhost ) || isProductionDomain
106112
107113 if ( ! shouldShowButton ) {
108- console . log ( 'PWA: Button hidden - not installable, not iOS, not dev+localhost' )
114+ console . log ( 'PWA: Button hidden - not installable, not iOS, not dev+localhost, not production HTTPS ' )
109115 return null
110116 }
111117
112- console . log ( 'PWA: Button will show - installable:' , isInstallable , 'iOS:' , isIOS ( ) , 'dev+localhost:' , isDev && isLocalhost )
118+ console . log ( 'PWA: Button will show - installable:' , isInstallable , 'iOS:' , isIOS ( ) , 'dev+localhost:' , isDev && isLocalhost , 'production:' , isProductionDomain )
113119
114120 return (
115121 < >
0 commit comments