Spaces:
Runtime error
Runtime error
Download setup-https.ps1 from Dhurgh/FireTech-Message-server: direct link, hf CLI and curl.
- Browser
- Download file 3.55 kB
-
https://huggingface.co/spaces/Dhurgh/FireTech-Message-server/resolve/36b75a51cf6729bdc17a09eefd8a034dbe997c3e/setup-https.ps1
- Command line
-
hf download hf://spaces/Dhurgh/FireTech-Message-server@36b75a51cf6729bdc17a09eefd8a034dbe997c3e/setup-https.ps1
-
curl -L -o setup-https.ps1 https://huggingface.co/spaces/Dhurgh/FireTech-Message-server/resolve/36b75a51cf6729bdc17a09eefd8a034dbe997c3e/setup-https.ps1
3.55 kB
| # Ultimate Chat App - Quick HTTPS Setup for LAN Access | |
| # Run this in PowerShell from the project directory | |
| Write-Host "π Ultimate Chat App - HTTPS LAN Setup" -ForegroundColor Cyan | |
| Write-Host "=======================================" -ForegroundColor Cyan | |
| Write-Host "" | |
| # Get LAN IP | |
| $lanIP = (Get-NetIPAddress -AddressFamily IPv4 | Where-Object {$_.InterfaceAlias -notlike "*Loopback*" -and $_.IPAddress -notlike "169.254.*"}).IPAddress | Select-Object -First 1 | |
| if (!$lanIP) { | |
| Write-Host "β Could not detect LAN IP address" -ForegroundColor Red | |
| exit 1 | |
| } | |
| Write-Host "π‘ Detected LAN IP: $lanIP" -ForegroundColor Green | |
| Write-Host "" | |
| # Stop existing Node processes | |
| Write-Host "π Stopping existing Node processes..." -ForegroundColor Yellow | |
| taskkill /F /IM node.exe 2>$null | Out-Null | |
| # Create certs directory | |
| Write-Host "π Creating certs directory..." -ForegroundColor Yellow | |
| New-Item -ItemType Directory -Force .\certs | Out-Null | |
| # Add firewall rule | |
| Write-Host "π₯ Adding Windows Firewall rule..." -ForegroundColor Yellow | |
| $existingRule = Get-NetFirewallRule -DisplayName "Chat App HTTPS" -ErrorAction SilentlyContinue | |
| if (!$existingRule) { | |
| New-NetFirewallRule -DisplayName "Chat App HTTPS" -Direction Inbound -LocalPort 3001 -Protocol TCP -Action Allow | Out-Null | |
| Write-Host "β Firewall rule added" -ForegroundColor Green | |
| } else { | |
| Write-Host "β Firewall rule already exists" -ForegroundColor Green | |
| } | |
| # Generate certificate | |
| Write-Host "π Generating HTTPS certificate for localhost and $lanIP..." -ForegroundColor Yellow | |
| $cert = New-SelfSignedCertificate ` | |
| -Subject "CN=localhost" ` | |
| -CertStoreLocation "Cert:\CurrentUser\My" ` | |
| -KeyAlgorithm RSA -KeyLength 2048 ` | |
| -HashAlgorithm SHA256 ` | |
| -NotAfter (Get-Date).AddYears(2) ` | |
| -TextExtension @("2.5.29.17={text}DNS=localhost&IPAddress=$lanIP") | |
| # Export certificate | |
| $pwd = ConvertTo-SecureString "123456" -AsPlainText -Force | |
| Export-PfxCertificate -Cert $cert -FilePath ".\certs\lan-localhost.pfx" -Password $pwd | Out-Null | |
| Export-Certificate -Cert $cert -FilePath ".\certs\lan-localhost.cer" -Force | Out-Null | |
| Write-Host "β Certificate generated" -ForegroundColor Green | |
| # Trust certificate | |
| Write-Host "π Trusting certificate..." -ForegroundColor Yellow | |
| Import-Certificate -FilePath ".\certs\lan-localhost.cer" -CertStoreLocation "Cert:\CurrentUser\Root" | Out-Null | |
| Write-Host "β Certificate trusted" -ForegroundColor Green | |
| Write-Host "" | |
| # Set environment variables | |
| $env:SSL_PFX_PATH = (Resolve-Path ".\certs\lan-localhost.pfx").Path | |
| $env:SSL_PFX_PASSPHRASE = "123456" | |
| $env:PORT = "3001" | |
| # Display access URLs | |
| Write-Host "βββββββββββββββββββββββββββββββββββββββββ" -ForegroundColor Cyan | |
| Write-Host "β π Setup Complete! β" -ForegroundColor Cyan | |
| Write-Host "βββββββββββββββββββββββββββββββββββββββββ" -ForegroundColor Cyan | |
| Write-Host "" | |
| Write-Host "Access URLs:" -ForegroundColor Yellow | |
| Write-Host " π± On this PC: https://localhost:3001" -ForegroundColor White | |
| Write-Host " π± On LAN devices: https://$lanIP:3001" -ForegroundColor White | |
| Write-Host "" | |
| Write-Host "Note: Mobile devices will show a certificate warning." -ForegroundColor Gray | |
| Write-Host " Click 'Advanced' β 'Proceed' to continue." -ForegroundColor Gray | |
| Write-Host "" | |
| Write-Host "Starting server..." -ForegroundColor Yellow | |
| Write-Host "" | |
| # Start the app | |
| npm start | |