feat: test ngrok

This commit is contained in:
lucas-neynar 2025-03-14 12:49:12 -07:00
parent 064919a0fa
commit b45798015f
No known key found for this signature in database
3 changed files with 257 additions and 9748 deletions

21
dev.js
View File

@ -1,4 +1,5 @@
import localtunnel from 'localtunnel'; // import localtunnel from 'localtunnel';
import ngrok from 'ngrok';
import { spawn } from 'child_process'; import { spawn } from 'child_process';
let tunnel; let tunnel;
@ -6,14 +7,16 @@ let nextDev;
let isCleaningUp = false; let isCleaningUp = false;
async function startDev() { async function startDev() {
// Start localtunnel and get URL // Start ngrok and get URL
tunnel = await localtunnel({ port: 3000 }); tunnel = await ngrok.connect({
console.log(`\n🌐 Local tunnel URL: ${tunnel.url}`); addr: 3000,
});
console.log(`\n🌐 Ngrok tunnel URL: ${tunnel}`);
// Start next dev with the tunnel URL as relevant environment variables // Start next dev with the tunnel URL as relevant environment variables
nextDev = spawn('next', ['dev'], { nextDev = spawn('next', ['dev'], {
stdio: 'inherit', stdio: 'inherit',
env: { ...process.env, NEXT_PUBLIC_URL: tunnel.url, NEXTAUTH_URL: tunnel.url } env: { ...process.env, NEXT_PUBLIC_URL: tunnel, NEXTAUTH_URL: tunnel }
}); });
// Handle cleanup // Handle cleanup
@ -28,8 +31,10 @@ async function startDev() {
} }
if (tunnel) { if (tunnel) {
await tunnel.close(); // Comment out localtunnel cleanup
console.log('\n🌐 Tunnel closed'); // await tunnel.close();
await ngrok.kill(); // Kill all ngrok processes
console.log('\n🌐 Ngrok tunnel closed');
} }
} catch (error) { } catch (error) {
console.error('Error during cleanup:', error); console.error('Error during cleanup:', error);
@ -41,7 +46,7 @@ async function startDev() {
// Handle process termination // Handle process termination
process.on('SIGINT', cleanup); process.on('SIGINT', cleanup);
process.on('SIGTERM', cleanup); process.on('SIGTERM', cleanup);
tunnel.on('close', cleanup); // tunnel.on('close', cleanup); // Remove localtunnel event listener
} }
startDev().catch(console.error); startDev().catch(console.error);

9989
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -40,6 +40,7 @@
"lucide-react": "^0.469.0", "lucide-react": "^0.469.0",
"next": "15.0.3", "next": "15.0.3",
"next-auth": "^4.24.11", "next-auth": "^4.24.11",
"ngrok": "^5.0.0-beta.2",
"ox": "^0.4.2", "ox": "^0.4.2",
"react": "^18", "react": "^18",
"react-dom": "^18", "react-dom": "^18",