File tree Expand file tree Collapse file tree 3 files changed +25
-4
lines changed
Expand file tree Collapse file tree 3 files changed +25
-4
lines changed Original file line number Diff line number Diff line change 11import type { NextConfig } from "next" ;
2+ import { webpack } from "next/dist/compiled/webpack/webpack" ;
23
34const nextConfig : NextConfig = {
45 /* config options here */
@@ -10,6 +11,18 @@ const nextConfig: NextConfig = {
1011 publicRuntimeConfig : {
1112 JWT_SECRET : process . env . JWT_SECRET ,
1213 } ,
14+
15+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
16+ webpack : ( config , { isServer } ) => {
17+ // Ensure environment variables are always available
18+ config . plugins . push (
19+ new webpack . DefinePlugin ( {
20+ 'process.env.JWT_SECRET' : JSON . stringify ( process . env . JWT_SECRET ) ,
21+ 'process.env.DATABASE_URL' : JSON . stringify ( process . env . DATABASE_URL ) ,
22+ } )
23+ ) ;
24+ return config ;
25+ }
1326} ;
1427
1528export default nextConfig ;
Original file line number Diff line number Diff line change @@ -58,10 +58,12 @@ export const authOptions: NextAuthOptions = {
5858 token . id = user . id ;
5959 token . email = user . email ;
6060 }
61-
61+ if ( ! process . env . JWT_SECRET ) {
62+ throw new Error ( "JWT_SECRET is ABSOLUTELY REQUIRED and not set" ) ;
63+ }
6264 token . accessToken = jwt . sign (
6365 { id : token . id , email : token . email } ,
64- process . env . NEXT_PUBLIC_JWT_SECRET || "" ,
66+ process . env . JWT_SECRET ,
6567 { expiresIn : "7d" }
6668 ) ;
6769 return token ;
@@ -75,5 +77,5 @@ export const authOptions: NextAuthOptions = {
7577 return session ;
7678 } ,
7779 } ,
78- secret : process . env . NEXT_PUBLIC_JWT_SECRET ,
80+ secret : process . env . JWT_SECRET ,
7981} ;
Original file line number Diff line number Diff line change @@ -12,7 +12,13 @@ ARG JWT_SECRET
1212# Set environment variables
1313ENV DATABASE_URL=${DATABASE_URL}
1414ENV JWT_SECRET=${JWT_SECRET}
15- ENV NEXT_PUBLIC_JWT_SECRET=${JWT_SECRET}
15+
16+ # Debugging step
17+ RUN echo "DATABASE_URL length: ${#DATABASE_URL}"
18+ RUN echo "JWT_SECRET length: ${#JWT_SECRET}"
19+
20+ # Fail if secrets are not set
21+ RUN test -n "$DATABASE_URL" && test -n "$JWT_SECRET"
1622
1723# Copy necessary files for dependency installation
1824COPY ./packages ./packages
You can’t perform that action at this time.
0 commit comments