This commit is contained in:
aaron 2026-05-12 11:07:45 +08:00
parent bf6bdb1255
commit 7215558813
5 changed files with 14 additions and 7 deletions

View File

@ -22,10 +22,8 @@ services:
web:
build:
context: ./web
args:
NEXT_PUBLIC_API_BASE_URL: http://127.0.0.1:8000/api/v1
environment:
NEXT_PUBLIC_API_BASE_URL: http://127.0.0.1:8000/api/v1
API_INTERNAL_URL: http://backend:8000
ports:
- "3000:3000"
depends_on:

View File

@ -1 +1 @@
NEXT_PUBLIC_API_BASE_URL=http://127.0.0.1:8000/api/v1
API_INTERNAL_URL=http://127.0.0.1:8000

View File

@ -5,8 +5,6 @@ RUN npm ci
FROM node:22-alpine AS builder
WORKDIR /app
ARG NEXT_PUBLIC_API_BASE_URL=http://127.0.0.1:8000/api/v1
ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build
@ -16,6 +14,7 @@ WORKDIR /app
ENV NODE_ENV=production
ENV HOSTNAME=0.0.0.0
ENV PORT=3000
ENV API_INTERNAL_URL=http://backend:8000
COPY --from=builder /app ./
EXPOSE 3000
CMD ["npm", "run", "start"]

View File

@ -1,4 +1,4 @@
export const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL || "http://127.0.0.1:8000/api/v1";
export const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL || "/api/v1";
const TOKEN_KEY = "cyber_mister_token";
const CLIENT_KEY = "cyber_mister_client_id";

View File

@ -2,6 +2,16 @@ import type { NextConfig } from "next";
const nextConfig: NextConfig = {
reactStrictMode: true,
async rewrites() {
const apiInternalUrl = process.env.API_INTERNAL_URL || "http://127.0.0.1:8000";
return [
{
source: "/api/:path*",
destination: `${apiInternalUrl}/api/:path*`,
},
];
},
};
export default nextConfig;