- add: frontend webpage for login/register

This commit is contained in:
2024-12-17 17:03:55 -05:00
parent c67cdd5b2a
commit 9c61b1b3f2
20 changed files with 29819 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
import axios from "axios";
const CONSUL_URL = process.env.REACT_APP_CONSUL_URL;
/**
* Fetch the IP and port of the service from Consul.
* @param {string} serviceName - The name of the registered service.
* @returns {Promise<{Address: string, ServicePort: number}>}
*/
export async function getServiceAddress(serviceName) {
try {
const response = await axios.get(`${CONSUL_URL}/v1/catalog/service/${serviceName}`);
if (response.data && response.data.length > 0) {
const { ServiceAddress, ServicePort } = response.data[0]; // Get the first instance
return { ServiceAddress, ServicePort };
} else {
throw new Error("Service not found in Consul");
}
} catch (error) {
console.error("Failed to fetch service address from Consul:", error);
throw error;
}
}