From 0defbfea5a4dfff161f959fa8dd91eec0068217e Mon Sep 17 00:00:00 2001 From: JBB0807 <104856796+JBB0807@users.noreply.github.com> Date: Fri, 2 May 2025 18:33:50 -0700 Subject: [PATCH] bug fix for fly server --- assignment-db-service/fly.toml | 35 ++++++++++++++++++++--------- assignment-service/.env | 1 + assignment-service/.env.development | 2 +- assignment-service/.env.test | 2 +- assignment-service/server.js | 2 +- auth-service/.env | 1 + auth-service/.env.development | 1 + auth-service/passport.js | 2 +- auth-service/server.js | 1 - user-db-service/fly.toml | 7 ++---- 10 files changed, 33 insertions(+), 21 deletions(-) diff --git a/assignment-db-service/fly.toml b/assignment-db-service/fly.toml index 18fc89d..4f08c1f 100644 --- a/assignment-db-service/fly.toml +++ b/assignment-db-service/fly.toml @@ -7,26 +7,39 @@ app = 'db-assignment-service' primary_region = 'sea' [build] +# Only needed if you're using a Dockerfile — can be empty if using buildpacks or Node preset -[http_service] - internal_port = 3000 - force_https = true - auto_stop_machines = 'stop' - auto_start_machines = true - min_machines_running = 0 - processes = ['app'] +# Removed the [http_service] section to disable public HTTP/HTTPS access +# [http_service] +# internal_port = 3000 +# force_https = true +# auto_stop_machines = true +# auto_start_machines = true +# min_machines_running = 0 +# processes = ["app"] [[services]] - protocol = 'tcp' + protocol = "tcp" internal_port = 3000 - ports = [] + internal_only = true # Makes this service only accessible internally + auto_start_machines = true + auto_stop_machines = true + + # Removed public port exposure + # [[services.ports]] + # port = 80 + # handlers = ["http"] + + # [[services.ports]] + # port = 443 + # handlers = ["tls", "http"] [services.concurrency] - type = 'requests' + type = "requests" hard_limit = 1000 soft_limit = 500 [[vm]] memory = '1gb' - cpu_kind = 'shared' + cpu_kind = "shared" cpus = 1 diff --git a/assignment-service/.env b/assignment-service/.env index b948690..9cf3674 100644 --- a/assignment-service/.env +++ b/assignment-service/.env @@ -1,2 +1,3 @@ #DB_ASSIGNMENT_SERVICE_URL = "http://localhost:3000" DB_ASSIGNMENT_SERVICE_URL = "http://db-assignment-service.internal:3000" +NODE_PORT = 8080 \ No newline at end of file diff --git a/assignment-service/.env.development b/assignment-service/.env.development index 1bc73e5..b0a3aab 100644 --- a/assignment-service/.env.development +++ b/assignment-service/.env.development @@ -3,4 +3,4 @@ NODE_ENV=development DB_ASSIGNMENT_SERVICE_URL="http://localhost:3200" AUTH_SESSION_KEY="f3f4d8e6b17a4b3abdc8e9a2c0457aaf91c0d5f6e3b7a9c8df624bd71ea35f42" ACCEPTED_ORIGINS=http://localhost:3000,http://localhost:8081,http://localhost:3001,http://localhost:5173 -PORT=8082 \ No newline at end of file +NODE_PORT=8082 \ No newline at end of file diff --git a/assignment-service/.env.test b/assignment-service/.env.test index d39a82f..8323fe9 100644 --- a/assignment-service/.env.test +++ b/assignment-service/.env.test @@ -3,4 +3,4 @@ NODE_ENV=development DB_ASSIGNMENT_SERVICE_URL="http://js-assignment-db-service:3200" AUTH_SESSION_KEY="f3f4d8e6b17a4b3abdc8e9a2c0457aaf91c0d5f6e3b7a9c8df624bd71ea35f42" ACCEPTED_ORIGINS=http://localhost:3000,http://localhost:8081,http://localhost:3001,http://localhost:5173 -PORT=8082 \ No newline at end of file +NODE_PORT=8082 \ No newline at end of file diff --git a/assignment-service/server.js b/assignment-service/server.js index 875a189..354b1f4 100644 --- a/assignment-service/server.js +++ b/assignment-service/server.js @@ -39,5 +39,5 @@ app.use(cors()); app.use("/instructor", instructorRouter); app.use("/student", studentRouter); -const port = process.env.PORT || 8080; +const port = process.env.NODE_PORT || 8080; app.listen(port, () => console.log(`Listening on port ${port}...`)); \ No newline at end of file diff --git a/auth-service/.env b/auth-service/.env index 4fe65d0..a5e74f3 100644 --- a/auth-service/.env +++ b/auth-service/.env @@ -6,6 +6,7 @@ ACCEPTED_ORIGINS ="https://bytecamp-web.fly.dev,https://byte-camp-auth-service.f #DB_USER_SERVICE_URL = "http://localhost:3000/" DB_USER_SERVICE_URL = "http://db-user-service.internal:3000/" AUTH_SESSION_KEY = "f3f4d8e6b17a4b3abdc8e9a2c0457aaf91c0d5f6e3b7a9c8df624bd71ea35f42" +ASSIGNMENT_SERVICE_URL="http://assignment-service.internal:8080" # fly secrets set GOOGLE_CALLBACK_URL=https://byte-camp-auth-service.fly.dev/auth/google/callback #fly secrets set GOOGLE_CLIENT_ID=485880105639-1in8tvb6ondnn198rasuj2d8ank06ntp.apps.googleusercontent.com GOOGLE_CLIENT_SECRET=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 LOGIN_REDIRECT_URL=https://bytecamp-web.fly.dev/ DB_USER_SERVICE_URL=https://db-user-service.fly.dev:3000/ AUTH_SESSION_KEY=f3f4d8e6b17a4b3abdc8e9a2c0457aaf91c0d5f6e3b7a9c8df624bd71ea35f42 \ No newline at end of file diff --git a/auth-service/.env.development b/auth-service/.env.development index 91cdcab..e302c2f 100644 --- a/auth-service/.env.development +++ b/auth-service/.env.development @@ -5,6 +5,7 @@ GOOGLE_CLIENT_SECRET="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" GOOGLE_CALLBACK_URL="http://localhost:8080/auth/google/callback" LOGIN_REDIRECT_URL="http://localhost:5173/" ACCEPTED_ORIGINS=http://localhost:3000,http://localhost:8081,http://localhost:3001,http://localhost:5173 +ASSIGNMENT_SERVICE_URL="http://localhost:8082/" DB_USER_SERVICE_URL="http://localhost:3100/" AUTH_SESSION_KEY="f3f4d8e6b17a4b3abdc8e9a2c0457aaf91c0d5f6e3b7a9c8df624bd71ea35f42" PORT=8080 \ No newline at end of file diff --git a/auth-service/passport.js b/auth-service/passport.js index 1448a9d..8ef091d 100644 --- a/auth-service/passport.js +++ b/auth-service/passport.js @@ -31,7 +31,7 @@ passport.use( try { console.log("Sending request to external auth service..."); const response = await axios.post( - "http://localhost:8082/student/verify", + `${process.env.ASSIGNMENT_SERVICE_URL}/student/verify`, { assignmentId, password, diff --git a/auth-service/server.js b/auth-service/server.js index f9ac814..924dfac 100644 --- a/auth-service/server.js +++ b/auth-service/server.js @@ -35,7 +35,6 @@ app.use( }) ) - app.use(express.json()); app.use("/auth", authRoute); diff --git a/user-db-service/fly.toml b/user-db-service/fly.toml index 07d92c2..30dbd0d 100644 --- a/user-db-service/fly.toml +++ b/user-db-service/fly.toml @@ -6,11 +6,6 @@ primary_region = "sea" [build] # Only needed if you're using a Dockerfile — can be empty if using buildpacks or Node preset -#[env] - #NODE_ENV = "production" - #DATABASE_URL = "postgresql://user:password@hostname:port/dbname" - # you can also leave DATABASE_URL unset here and use secrets instead - # Removed the [http_service] section to disable public HTTP/HTTPS access # [http_service] # internal_port = 3000 @@ -24,6 +19,8 @@ primary_region = "sea" protocol = "tcp" internal_port = 3000 internal_only = true # Makes this service only accessible internally + auto_start_machines = true + auto_stop_machines = true # Removed public port exposure # [[services.ports]]