mirror of
https://github.com/neynarxyz/create-farcaster-mini-app.git
synced 2025-11-16 08:08:56 -05:00
feat: test ngrok
This commit is contained in:
parent
064919a0fa
commit
b45798015f
21
dev.js
21
dev.js
@ -1,4 +1,5 @@
|
||||
import localtunnel from 'localtunnel';
|
||||
// import localtunnel from 'localtunnel';
|
||||
import ngrok from 'ngrok';
|
||||
import { spawn } from 'child_process';
|
||||
|
||||
let tunnel;
|
||||
@ -6,14 +7,16 @@ let nextDev;
|
||||
let isCleaningUp = false;
|
||||
|
||||
async function startDev() {
|
||||
// Start localtunnel and get URL
|
||||
tunnel = await localtunnel({ port: 3000 });
|
||||
console.log(`\n🌐 Local tunnel URL: ${tunnel.url}`);
|
||||
// Start ngrok and get URL
|
||||
tunnel = await ngrok.connect({
|
||||
addr: 3000,
|
||||
});
|
||||
console.log(`\n🌐 Ngrok tunnel URL: ${tunnel}`);
|
||||
|
||||
// Start next dev with the tunnel URL as relevant environment variables
|
||||
nextDev = spawn('next', ['dev'], {
|
||||
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
|
||||
@ -28,8 +31,10 @@ async function startDev() {
|
||||
}
|
||||
|
||||
if (tunnel) {
|
||||
await tunnel.close();
|
||||
console.log('\n🌐 Tunnel closed');
|
||||
// Comment out localtunnel cleanup
|
||||
// await tunnel.close();
|
||||
await ngrok.kill(); // Kill all ngrok processes
|
||||
console.log('\n🌐 Ngrok tunnel closed');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error during cleanup:', error);
|
||||
@ -41,7 +46,7 @@ async function startDev() {
|
||||
// Handle process termination
|
||||
process.on('SIGINT', cleanup);
|
||||
process.on('SIGTERM', cleanup);
|
||||
tunnel.on('close', cleanup);
|
||||
// tunnel.on('close', cleanup); // Remove localtunnel event listener
|
||||
}
|
||||
|
||||
startDev().catch(console.error);
|
||||
9989
package-lock.json
generated
9989
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -40,6 +40,7 @@
|
||||
"lucide-react": "^0.469.0",
|
||||
"next": "15.0.3",
|
||||
"next-auth": "^4.24.11",
|
||||
"ngrok": "^5.0.0-beta.2",
|
||||
"ox": "^0.4.2",
|
||||
"react": "^18",
|
||||
"react-dom": "^18",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user