diff --git a/Frontend/.env b/Frontend/.env new file mode 100644 index 0000000..0f48cea --- /dev/null +++ b/Frontend/.env @@ -0,0 +1,4 @@ +NEXT_PUBLIC_API_URL="https://projektbackend.lona-development.org" +API_URL="https://projektbackend.lona-development.org" +NEXTAUTH_SECRET="fuerfortnite" +NEXTAUTH_URL="https://projekt.lona-development.org" diff --git a/Frontend/Dockerfile b/Frontend/Dockerfile index b6b4ebd..d94b8d2 100644 --- a/Frontend/Dockerfile +++ b/Frontend/Dockerfile @@ -11,6 +11,10 @@ FROM base AS builder WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . + +ARG NEXT_PUBLIC_API_URL +ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL + RUN npm run build # Production image, copy all the files and run next diff --git a/Frontend/app/api/auth/[...nextauth]/route.ts b/Frontend/app/api/auth/[...nextauth]/route.ts index 7c9d29b..f8685a1 100644 --- a/Frontend/app/api/auth/[...nextauth]/route.ts +++ b/Frontend/app/api/auth/[...nextauth]/route.ts @@ -15,7 +15,7 @@ const handler = NextAuth({ if (!credentials?.email || !credentials?.password) return null try { - const res = await fetch(`${process.env.API_URL || 'http://localhost:8080'}/api/auth/login`, { + const res = await fetch(`${process.env.API_URL}/api/auth/login`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ diff --git a/Frontend/lib/auth-context.tsx b/Frontend/lib/auth-context.tsx index 7adba99..fffd985 100644 --- a/Frontend/lib/auth-context.tsx +++ b/Frontend/lib/auth-context.tsx @@ -4,7 +4,7 @@ import { createContext, useContext, useState, useCallback, useEffect, type React import { useSession, signIn, signOut } from "next-auth/react" import type { User, Ticket, TicketStatus, Room } from "./types" -const API_URL = process.env.NEXT_PUBLIC_API_URL || "http://localhost:8080/api" +const API_URL = process.env.NEXT_PUBLIC_API_URL interface AuthContextType { user: User | null diff --git a/docker-compose.yml b/docker-compose.yml index 47bc85a..389aae9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,7 +26,10 @@ services: restart: unless-stopped frontend: - build: ./Frontend + build: + context: ./Frontend + args: + NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL} container_name: ticketsystem-frontend environment: NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-http://projekt.lona-development.org/api}