mirror of
https://github.com/neynarxyz/create-farcaster-mini-app.git
synced 2025-11-16 08:08:56 -05:00
pass localtunnel url to dev server
This commit is contained in:
parent
b168e34521
commit
109569924d
37
dev.js
Normal file
37
dev.js
Normal file
@ -0,0 +1,37 @@
|
||||
import localtunnel from 'localtunnel';
|
||||
import { spawn } from 'child_process';
|
||||
|
||||
let tunnel;
|
||||
let nextDev;
|
||||
|
||||
async function startDev() {
|
||||
// Start localtunnel and get URL
|
||||
tunnel = await localtunnel({ port: 3000 });
|
||||
console.log(`\n🌐 Local tunnel URL: ${tunnel.url}`);
|
||||
|
||||
// Start next dev with the tunnel URL as an environment variable
|
||||
nextDev = spawn('next', ['dev'], {
|
||||
stdio: 'inherit',
|
||||
env: { ...process.env, NEXT_PUBLIC_URL: tunnel.url }
|
||||
});
|
||||
|
||||
// Handle cleanup
|
||||
const cleanup = () => {
|
||||
if (tunnel) {
|
||||
tunnel.close();
|
||||
console.log('\n🌐 Tunnel closed');
|
||||
}
|
||||
if (nextDev) {
|
||||
nextDev.kill();
|
||||
console.log('\n🛑 Next.js dev server stopped');
|
||||
}
|
||||
process.exit(0);
|
||||
};
|
||||
|
||||
// Handle process termination
|
||||
process.on('SIGINT', cleanup);
|
||||
process.on('SIGTERM', cleanup);
|
||||
tunnel.on('close', cleanup);
|
||||
}
|
||||
|
||||
startDev().catch(console.error);
|
||||
@ -14,7 +14,8 @@
|
||||
"web3"
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "lt --port 3000 & next dev",
|
||||
"localtunnel": "node localtunnel.js",
|
||||
"dev": "node dev.js",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user