Skip to content

Commit 1d99b52

Browse files
committed
fix(build): configure JWT_SECRET for Next.js build and GitHub workflow
1 parent 9250e31 commit 1d99b52

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

.github/workflows/cd_frontend.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,3 @@ jobs:
2525
JWT_SECRET=${{ secrets.JWT_SECRET }}
2626
push: true
2727
tags: coderomm/collabydraw:${{ github.sha }}
28-
## Step to deploy this to a VM

apps/collabydraw/next.config.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ import type { NextConfig } from "next";
22

33
const nextConfig: NextConfig = {
44
/* config options here */
5-
reactStrictMode: false,
5+
env: {
6+
JWT_SECRET: process.env.JWT_SECRET,
7+
DATABASE_URL: process.env.DATABASE_URL,
8+
},
9+
10+
publicRuntimeConfig: {
11+
JWT_SECRET: process.env.JWT_SECRET,
12+
},
613
};
714

815
export default nextConfig;

apps/collabydraw/utils/auth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const authOptions: NextAuthOptions = {
6161

6262
token.accessToken = jwt.sign(
6363
{ id: token.id, email: token.email },
64-
process.env.NEXTAUTH_SECRET || "",
64+
process.env.NEXT_PUBLIC_JWT_SECRET || "",
6565
{ expiresIn: "7d" }
6666
);
6767
return token;
@@ -75,5 +75,5 @@ export const authOptions: NextAuthOptions = {
7575
return session;
7676
},
7777
},
78-
secret: process.env.NEXTAUTH_SECRET,
78+
secret: process.env.NEXT_PUBLIC_JWT_SECRET,
7979
};

docker/Dockerfile.frontend

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ WORKDIR /usr/src/app
88
# Add ARG for DATABASE_URL
99
ARG DATABASE_URL
1010
ARG JWT_SECRET
11-
# ENV DATABASE_URL=${DATABASE_URL}
11+
12+
# Set environment variables
13+
ENV DATABASE_URL=${DATABASE_URL}
14+
ENV JWT_SECRET=${JWT_SECRET}
15+
ENV NEXT_PUBLIC_JWT_SECRET=${JWT_SECRET}
1216

1317
# Copy necessary files for dependency installation
1418
COPY ./packages ./packages
@@ -34,9 +38,10 @@ RUN prisma generate
3438
# Change back to the root directory
3539
WORKDIR /usr/src/app
3640

41+
# Debug step: print environment variables
42+
RUN echo "DATABASE_URL: ${DATABASE_URL}" && echo "JWT_SECRET set: ${JWT_SECRET:+yes}"
43+
3744
# Build the application with database URL
38-
ENV DATABASE_URL=${DATABASE_URL}
39-
ENV JWT_SECRET=${JWT_SECRET}
4045
RUN pnpm run build
4146

4247
# Expose the port

0 commit comments

Comments
 (0)