Fix incorrect public IP address display on main page by using a server-side endpoint for IP retrieval.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 9111ef36-26c8-4085-84ca-a35dc1fec1b5
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7083d608-d6d3-4a6a-9a27-6286c5109627/3e698266-b052-42ed-97e7-da236cf5d31f.jpg
This commit is contained in:
alphaeusmote
2025-04-11 17:01:12 +00:00
parent 57b9812036
commit b5c0d15530
2 changed files with 32 additions and 13 deletions
+19
View File
@@ -155,6 +155,25 @@ async function triggerDnsWebhooks(
export async function registerRoutes(app: Express): Promise<Server> {
// Setup authentication routes
setupAuth(app);
// Add public IP endpoint for the frontend
app.get('/api/public-ip', async (req, res) => {
try {
console.log('Fetching public IP addresses');
// Get IPv4 address using our utility function
const ipv4 = await getCurrentIpAddress();
console.log(`Resolved IPv4: ${ipv4}`);
// Try to get IPv6 as well
const ipv6 = await getCurrentIpv6Address();
console.log(`Resolved IPv6: ${ipv6}`);
res.json({ ipv4, ipv6 });
} catch (error) {
console.error('Error getting public IP:', error);
res.status(500).json({ error: 'Failed to get public IP address' });
}
});
// DNS Records routes
app.get("/api/dns-records", requireRole(["admin", "manager", "user", "readonly"]), async (req, res) => {