diff --git a/apps/web/package.json b/apps/web/package.json index b2780cd4..bc379554 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -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", diff --git a/apps/web/src/app/api/network/lan-ip/route.ts b/apps/web/src/app/api/network/lan-ip/route.ts deleted file mode 100644 index 08f64b8b..00000000 --- a/apps/web/src/app/api/network/lan-ip/route.ts +++ /dev/null @@ -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 } - ) - } -} diff --git a/apps/web/src/components/worksheets/QRCodeDisplay.tsx b/apps/web/src/components/worksheets/QRCodeDisplay.tsx index e7b2c827..be2ec675 100644 --- a/apps/web/src/components/worksheets/QRCodeDisplay.tsx +++ b/apps/web/src/components/worksheets/QRCodeDisplay.tsx @@ -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 { - 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 { */ 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 {