forked from garvnn/meetup
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_api_url.js
More file actions
45 lines (41 loc) Β· 1.3 KB
/
Copy pathsetup_api_url.js
File metadata and controls
45 lines (41 loc) Β· 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env node
/**
* Setup script to configure the API URL for your PennApps app
* Run this after starting your backend server
*/
const { execSync } = require('child_process');
const os = require('os');
// Get the local IP address
function getLocalIP() {
const interfaces = os.networkInterfaces();
for (const name of Object.keys(interfaces)) {
for (const iface of interfaces[name]) {
if (iface.family === 'IPv4' && !iface.internal) {
return iface.address;
}
}
}
return 'localhost';
}
const localIP = getLocalIP();
const apiUrl = `http://${localIP}:8000`;
console.log('π PennApps API Setup');
console.log('==================');
console.log(`π± Your computer's IP: ${localIP}`);
console.log(`π API URL: ${apiUrl}`);
console.log('');
console.log('π To configure your app:');
console.log('');
console.log('1. Set environment variable:');
console.log(` export EXPO_PUBLIC_API_URL="${apiUrl}"`);
console.log('');
console.log('2. Or add to your .env file:');
console.log(` EXPO_PUBLIC_API_URL=${apiUrl}`);
console.log('');
console.log('3. Restart Expo:');
console.log(' npx expo start --clear');
console.log('');
console.log('4. Test the connection:');
console.log(` curl ${apiUrl}/health`);
console.log('');
console.log('β
Your backend should be running on this URL!');