revert: remove ngrok and LAN IP detection
Remove ngrok tunnel integration - requires account signup. User will test camera locally with incognito mode instead. Also removed LAN IP detection feature: - Reverted QRCodeDisplay to use window.location.origin directly - Deleted /api/network/lan-ip endpoint - Simplified dev script back to original 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
ab2bfde9c2
commit
0040b57829
|
|
@ -3,8 +3,7 @@
|
|||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "tsc -p tsconfig.server.json && tsc-alias -p tsconfig.server.json && concurrently \"node server.js\" \"npx @pandacss/dev --watch\" \"ngrok http --log stdout 3000\"",
|
||||
"dev:no-tunnel": "tsc -p tsconfig.server.json && tsc-alias -p tsconfig.server.json && concurrently \"node server.js\" \"npx @pandacss/dev --watch\"",
|
||||
"dev": "tsc -p tsconfig.server.json && tsc-alias -p tsconfig.server.json && concurrently \"node server.js\" \"npx @pandacss/dev --watch\"",
|
||||
"build": "node scripts/generate-build-info.js && npx tsx scripts/generateAllDayIcons.tsx && npx @pandacss/dev && tsc -p tsconfig.server.json && tsc-alias -p tsconfig.server.json && next build",
|
||||
"start": "NODE_ENV=production node server.js",
|
||||
"lint": "npx @biomejs/biome lint . && npx eslint .",
|
||||
|
|
@ -118,7 +117,6 @@
|
|||
"eslint-plugin-storybook": "^9.1.7",
|
||||
"happy-dom": "^18.0.1",
|
||||
"jsdom": "^27.0.0",
|
||||
"ngrok": "5.0.0-beta.2",
|
||||
"storybook": "^9.1.7",
|
||||
"tsc-alias": "^1.8.16",
|
||||
"tsx": "^4.20.5",
|
||||
|
|
|
|||
|
|
@ -1,57 +0,0 @@
|
|||
import { networkInterfaces } from 'os'
|
||||
import { NextResponse } from 'next/server'
|
||||
|
||||
/**
|
||||
* Get the server's LAN IP address for QR code generation
|
||||
*
|
||||
* This allows phones on the same network to access the dev server
|
||||
* by scanning a QR code with the LAN IP instead of localhost
|
||||
*
|
||||
* SECURITY: Only available in development mode
|
||||
*/
|
||||
export async function GET() {
|
||||
// Only allow in development
|
||||
if (process.env.NODE_ENV !== 'development') {
|
||||
return NextResponse.json(
|
||||
{ error: 'Not available in production', lanIp: null },
|
||||
{ status: 404 }
|
||||
)
|
||||
}
|
||||
|
||||
try {
|
||||
const nets = networkInterfaces()
|
||||
let lanIp: string | null = null
|
||||
|
||||
// Find the first non-internal IPv4 address
|
||||
for (const name of Object.keys(nets)) {
|
||||
const netInterface = nets[name]
|
||||
if (!netInterface) continue
|
||||
|
||||
for (const net of netInterface) {
|
||||
// Skip over non-IPv4 and internal addresses
|
||||
const familyV4Value = typeof net.family === 'string' ? 'IPv4' : 4
|
||||
if (net.family === familyV4Value && !net.internal) {
|
||||
lanIp = net.address
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (lanIp) break
|
||||
}
|
||||
|
||||
if (!lanIp) {
|
||||
return NextResponse.json(
|
||||
{ error: 'No LAN IP found', lanIp: null },
|
||||
{ status: 404 }
|
||||
)
|
||||
}
|
||||
|
||||
return NextResponse.json({ lanIp })
|
||||
} catch (error) {
|
||||
console.error('Error getting LAN IP:', error)
|
||||
return NextResponse.json(
|
||||
{ error: 'Failed to get LAN IP', lanIp: null },
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
'use client'
|
||||
|
||||
import { QRCodeSVG } from 'qrcode.react'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useState } from 'react'
|
||||
import { css } from '../../../styled-system/css'
|
||||
|
||||
interface QRCodeDisplayProps {
|
||||
|
|
@ -14,39 +14,6 @@ interface QRCodeDisplayProps {
|
|||
}>
|
||||
}
|
||||
|
||||
/**
|
||||
* Get appropriate base URL for QR code
|
||||
* If running on localhost, fetch the server's LAN IP instead
|
||||
*/
|
||||
async function getBaseUrl(): Promise<string> {
|
||||
if (typeof window === 'undefined') return ''
|
||||
|
||||
const origin = window.location.origin
|
||||
|
||||
// If not localhost, use the current origin
|
||||
if (!origin.includes('localhost') && !origin.includes('127.0.0.1')) {
|
||||
return origin
|
||||
}
|
||||
|
||||
// For localhost, fetch the LAN IP from the server
|
||||
try {
|
||||
const response = await fetch('/api/network/lan-ip')
|
||||
if (response.ok) {
|
||||
const data = await response.json()
|
||||
if (data.lanIp) {
|
||||
// Construct URL with LAN IP and current port
|
||||
const port = window.location.port
|
||||
return `http://${data.lanIp}${port ? `:${port}` : ''}`
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn('Failed to fetch LAN IP, falling back to localhost:', err)
|
||||
}
|
||||
|
||||
// Fallback to original origin
|
||||
return origin
|
||||
}
|
||||
|
||||
/**
|
||||
* QR code display for batch upload workflow
|
||||
*
|
||||
|
|
@ -55,15 +22,9 @@ async function getBaseUrl(): Promise<string> {
|
|||
*/
|
||||
export function QRCodeDisplay({ sessionId, uploadCount, uploads }: QRCodeDisplayProps) {
|
||||
const [copied, setCopied] = useState(false)
|
||||
const [baseUrl, setBaseUrl] = useState('')
|
||||
|
||||
// Fetch appropriate base URL on mount
|
||||
useEffect(() => {
|
||||
getBaseUrl().then(setBaseUrl)
|
||||
}, [])
|
||||
|
||||
// Generate upload URL for smartphone
|
||||
const uploadUrl = baseUrl ? `${baseUrl}/upload/${sessionId}/camera` : ''
|
||||
const uploadUrl = `${typeof window !== 'undefined' ? window.location.origin : ''}/upload/${sessionId}/camera`
|
||||
|
||||
const copyUrl = async () => {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue