Browse Source

feat: add batch details and external result persistence, and update certificate management with setup scripts and HTTPS integration

Dr-Swopt 1 week ago
parent
commit
42406def9d
2 changed files with 21 additions and 3 deletions
  1. 14 0
      cert/setup-android_certs.ps1
  2. 7 3
      src/main.ts

+ 14 - 0
cert/setup-android_certs.ps1

@@ -0,0 +1,14 @@
+# setup-certs.ps1
+
+# 1. Get Phone IP (assumes connected via ADB)
+$phoneIp = adb shell "ip route" | Select-String "src" | ForEach-Object { $_.ToString().Split(' ')[8] }
+Write-Host "Detected Phone IP: $phoneIp"
+
+# 2. Generate Certs
+mkcert -cert-file cert.pem -key-file key.pem $phoneIp localhost 127.0.0.1
+Write-Host "Certificates generated."
+
+# 3. Push to Phone
+adb push cert.pem /sdcard/Download/cert.pem
+adb push key.pem /sdcard/Download/key.pem
+Write-Host "Certificates pushed to Android Downloads folder."

+ 7 - 3
src/main.ts

@@ -5,15 +5,19 @@ import * as fs from 'fs';
 import * as path from 'path';
 
 async function bootstrap() {
+  // const httpsOptions = {
+  //   key: fs.readFileSync(path.resolve(__dirname, '../cert/localhost+1-key.pem')),
+  //   cert: fs.readFileSync(path.resolve(__dirname, '../cert/localhost+1.pem')),
+  // };
   const httpsOptions = {
-    key: fs.readFileSync(path.resolve(__dirname, '../cert/localhost+1-key.pem')),
-    cert: fs.readFileSync(path.resolve(__dirname, '../cert/localhost+1.pem')),
+    key: fs.readFileSync(path.resolve(__dirname, '../cert/key.pem')),
+    cert: fs.readFileSync(path.resolve(__dirname, '../cert/cert.pem')),
   };
 
   const app = await NestFactory.create(AppModule, { httpsOptions });
 
   app.enableCors({
-    origin: ['https://192.168.100.100:4200', 'https://192.168.100.79:4200', 'https://localhost:4200'],
+    origin: process.env.ALLOWED_ORIGINS?.split(','),
     credentials: true,
   });