Code changes to make it work with Fly.io
This commit is contained in:
parent
5b93901976
commit
0695a01f17
9 changed files with 100 additions and 85 deletions
|
|
@ -1,5 +1,10 @@
|
|||
CLIENT_ID = "485880105639-1in8tvb6ondnn198rasuj2d8ank06ntp.apps.googleusercontent.com"
|
||||
CLIENT_SECRET = "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"
|
||||
CLIENT_URL = "http://localhost:5173/"
|
||||
DB_USER_SERVICE_URL = "http://localhost:3000/"
|
||||
SESSION_KEY = "f3f4d8e6b17a4b3abdc8e9a2c0457aaf91c0d5f6e3b7a9c8df624bd71ea35f42"
|
||||
GOOGLE_CLIENT_ID = "485880105639-1in8tvb6ondnn198rasuj2d8ank06ntp.apps.googleusercontent.com"
|
||||
GOOGLE_CLIENT_SECRET = "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"
|
||||
GOOGLE_CALLBACK_URL = "https://byte-camp-auth-service.fly.dev/auth/google/callback"
|
||||
LOGIN_REDIRECT_URL = "https://bytecamp-web.fly.dev/"
|
||||
#DB_USER_SERVICE_URL = "http://localhost:3000/"
|
||||
DB_USER_SERVICE_URL = "http://db-user-service.internal:3000/"
|
||||
AUTH_SESSION_KEY = "f3f4d8e6b17a4b3abdc8e9a2c0457aaf91c0d5f6e3b7a9c8df624bd71ea35f42"
|
||||
|
||||
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
|
||||
|
|
@ -11,7 +11,7 @@ COPY . .
|
|||
RUN npm install
|
||||
|
||||
# Install dependencies using npm ci for deterministic builds
|
||||
RUN --mount=type=cache,target=/root/.npm npm ci --production
|
||||
# RUN --mount=type=cache,target=/root/.npm npm ci --production
|
||||
|
||||
# Copy the application source code
|
||||
COPY --link . .
|
||||
|
|
|
|||
|
|
@ -1,28 +1,42 @@
|
|||
# fly.toml app configuration file generated for snakebyte on 2025-01-04T01:06:05-08:00
|
||||
# fly.toml app configuration file generated for byte-camp-auth-service on 2025-04-21T14:38:25-07:00
|
||||
#
|
||||
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
|
||||
#
|
||||
|
||||
app = "auth-service"
|
||||
primary_region = "sea"
|
||||
app = 'byte-camp-auth-service'
|
||||
primary_region = 'sea'
|
||||
|
||||
[build]
|
||||
|
||||
[env]
|
||||
PORT = "8080"
|
||||
PORT = '8080'
|
||||
|
||||
[http_service]
|
||||
internal_port = 8080
|
||||
force_https = true
|
||||
auto_stop_machines = 'stop'
|
||||
auto_start_machines = true
|
||||
min_machines_running = 0
|
||||
processes = ['app']
|
||||
|
||||
[[services]]
|
||||
protocol = 'tcp'
|
||||
internal_port = 8080
|
||||
protocol = "tcp"
|
||||
|
||||
[[services.ports]]
|
||||
handlers = ["http"]
|
||||
port = 80
|
||||
handlers = ['http']
|
||||
|
||||
[[services.ports]]
|
||||
handlers = ["tls", "http"]
|
||||
port = 443
|
||||
handlers = ['tls', 'http']
|
||||
|
||||
[[services.tcp_checks]]
|
||||
interval = "10s"
|
||||
timeout = "2s"
|
||||
grace_period = "5s"
|
||||
restart_limit = 0
|
||||
interval = '10s'
|
||||
timeout = '2s'
|
||||
grace_period = '5s'
|
||||
|
||||
[[vm]]
|
||||
memory = '1gb'
|
||||
cpu_kind = 'shared'
|
||||
cpus = 1
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ const passport = require("passport");
|
|||
passport.use(
|
||||
new GoogleStrategy(
|
||||
{
|
||||
clientID: process.env.CLIENT_ID,
|
||||
clientSecret: process.env.CLIENT_SECRET,
|
||||
callbackURL: "/auth/google/callback",
|
||||
clientID: process.env.GOOGLE_CLIENT_ID,
|
||||
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
|
||||
callbackURL: process.env.GOOGLE_CALLBACK_URL,
|
||||
scope: ["profile", "email"],
|
||||
},
|
||||
function (accessToken, refreshToken, profile, callback) {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ router.get("/login", (req, res) => {
|
|||
})
|
||||
.then(response => {
|
||||
console.log("User registration response:", response.data);
|
||||
res.redirect(process.env.CLIENT_URL);
|
||||
res.redirect(process.env.LOGIN_REDIRECT_URL);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error("Error registering user:", error.message);
|
||||
|
|
@ -42,7 +42,7 @@ router.get("/google", passport.authenticate("google", ["profile", "email"]));
|
|||
|
||||
router.get("/logout", (req, res) => {
|
||||
req.logOut();
|
||||
res.redirect(process.env.CLIENT_URL);
|
||||
res.redirect(process.env.LOGIN_REDIRECT_URL);
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
|
@ -11,7 +11,7 @@ const app = express();
|
|||
|
||||
app.use(
|
||||
session({
|
||||
secret: process.env.SESSION_KEY,
|
||||
secret: process.env.AUTH_SESSION_KEY,
|
||||
resave: false,
|
||||
saveUninitialized: false,
|
||||
cookie: {
|
||||
|
|
@ -25,7 +25,7 @@ app.use(passport.session());
|
|||
|
||||
app.use(
|
||||
cors({
|
||||
origin: "http://localhost:5173",
|
||||
origin: "https://bytecamp-web.fly.dev",
|
||||
methods: "GET",
|
||||
credentials: true,
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue