now getting the correct IPV6 for proxy

This commit is contained in:
JBB0807 2025-05-07 23:30:37 -07:00
parent 7daa2e6cca
commit a494cd4f0a
5 changed files with 18 additions and 4 deletions

View file

@ -1,3 +1,4 @@
DB_ASSIGNMENT_SERVICE_URL = "http://db-assignment-service.internal:3000" DB_ASSIGNMENT_SERVICE_URL = "http://db-assignment-service.internal:3000"
DEPLOY_API_URL="http://localhost:3006" DEPLOY_API_URL="http://localhost:3006"
PROXY_URL="https://proxy-service.fly.dev"
NODE_PORT = 8080 NODE_PORT = 8080

View file

@ -8,4 +8,6 @@ AWS_REGION='auto'
AWS_SECRET_ACCESS_KEY='tsec_6Bz1aMbfYQftuq5WfIVEDZkHwskU4MMjVywdtxSP6uxetEBvkSC2VHI9HfTeDgHr4D6kiz' AWS_SECRET_ACCESS_KEY='tsec_6Bz1aMbfYQftuq5WfIVEDZkHwskU4MMjVywdtxSP6uxetEBvkSC2VHI9HfTeDgHr4D6kiz'
COMMON_BUCKET='snakeapi-deployment-test-bucket' COMMON_BUCKET='snakeapi-deployment-test-bucket'
PROXY_URL="https://proxy-service.fly.dev"
NODE_PORT=8082 NODE_PORT=8082

View file

@ -1,4 +1,5 @@
NODE_ENV=docker NODE_ENV=docker
DB_ASSIGNMENT_SERVICE_URL="http://js-assignment-db-service:3200" DB_ASSIGNMENT_SERVICE_URL="http://js-assignment-db-service:3200"
DEPLOY_API_URL="http://js-deployment-service:3006/deploy" DEPLOY_API_URL="http://js-deployment-service:3006/deploy"
NODE_PORT=8082 NODE_PORT=8082
PROXY_URL="https://proxy-service.fly.dev"

View file

@ -8,6 +8,7 @@ const DB_ASSIGNMENT_SERVICE_URL =
process.env.DB_ASSIGNMENT_SERVICE_URL || "http://localhost:3000"; process.env.DB_ASSIGNMENT_SERVICE_URL || "http://localhost:3000";
const DEPLOY_API_URL = process.env.DEPLOY_API_URL || "http://localhost:3600"; const DEPLOY_API_URL = process.env.DEPLOY_API_URL || "http://localhost:3600";
const PROXY_URL = process.env.PROXY_URL;
console.log("DB_ASSIGNMENT_SERVICE_URL:", DB_ASSIGNMENT_SERVICE_URL); console.log("DB_ASSIGNMENT_SERVICE_URL:", DB_ASSIGNMENT_SERVICE_URL);
console.log("DEPLOY_API_URL:", DEPLOY_API_URL); console.log("DEPLOY_API_URL:", DEPLOY_API_URL);
@ -63,8 +64,9 @@ intructorRouter.post(
// Update the assignment with the deployment details // Update the assignment with the deployment details
const updatedAssignmentData = { const updatedAssignmentData = {
assignmenturl: ipv6, assignmenturl: `${PROXY_URL}/${ipv6}`,
} }
console.log("Updating assignment with deployment details:", updatedAssignmentData); console.log("Updating assignment with deployment details:", updatedAssignmentData);
const updateRespone = await axios.put( const updateRespone = await axios.put(
`${DB_ASSIGNMENT_SERVICE_URL}/assignments/${assignmentId}`, `${DB_ASSIGNMENT_SERVICE_URL}/assignments/${assignmentId}`,

View file

@ -163,13 +163,21 @@ app.post("/deploy", async (req, res) => {
const ipv6 = v6resp.data.data.allocateIpAddress.ipAddress.address; const ipv6 = v6resp.data.data.allocateIpAddress.ipAddress.address;
console.log("Allocated IPv6:", ipv6); console.log("Allocated IPv6:", ipv6);
const machines = await fly.get(`/apps/${appName}/machines`);
const firstPrivateIp = machines.data[0]?.private_ip;
if (!firstPrivateIp) {
console.error("No private IP found for the machine:", machines.data);
return machines.status(500).json({ error: "No private IP found" });
}
console.log("First private IP:", firstPrivateIp);
return res.json({ return res.json({
status: "created", status: "created",
app: appName, app: appName,
ipv4, ipv4,
ipv6, ipv6 : firstPrivateIp,
url_v4: `http://${ipv4}`, url_v4: `http://${ipv4}`,
url_v6: `http://[${ipv6}]`, url_v6: `http://[${firstPrivateIp}]`,
}); });
} catch (err) { } catch (err) {
console.error( console.error(