mirror of
https://github.com/theoleuthardt/werkzeugkiste.git
synced 2026-06-13 01:27:54 +00:00
fix: use conditionally the right url for backend in nextjs frontend
This commit is contained in:
parent
2c7043eec6
commit
a3e7998d11
4 changed files with 13 additions and 5 deletions
4
.env
4
.env
|
|
@ -2,6 +2,4 @@
|
||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
HOSTNAME=0.0.0.0
|
HOSTNAME=0.0.0.0
|
||||||
FRONTEND_PORT=3000
|
FRONTEND_PORT=3000
|
||||||
BACKEND_PORT=4000
|
BACKEND_PORT=4000
|
||||||
NEXT_PUBLIC_BACKEND_URL=http://localhost:4000
|
|
||||||
CORS_ALLOWED_ORIGIN=http://localhost:3000
|
|
||||||
|
|
@ -10,6 +10,10 @@ import { generateQRCode } from "./src/routes/generateqrcode.route";
|
||||||
import { wordCounter } from "./src/routes/wordcounter.route";
|
import { wordCounter } from "./src/routes/wordcounter.route";
|
||||||
import { videoToAudio } from "./src/routes/videotoaudio.route";
|
import { videoToAudio } from "./src/routes/videotoaudio.route";
|
||||||
import { removeBG } from "./src/routes/removebg.route";
|
import { removeBG } from "./src/routes/removebg.route";
|
||||||
|
import dotenv from "dotenv";
|
||||||
|
import path from "node:path";
|
||||||
|
|
||||||
|
dotenv.config({ path: path.resolve(__dirname, "../.env") });
|
||||||
|
|
||||||
const app = Fastify({ logger: true });
|
const app = Fastify({ logger: true });
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ WORKDIR /app
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
ENV NODE_ENV=production
|
||||||
ARG NEXT_PUBLIC_BACKEND_URL
|
ARG NEXT_PUBLIC_BACKEND_URL
|
||||||
ENV NEXT_PUBLIC_BACKEND_URL=$NEXT_PUBLIC_BACKEND_URL
|
ENV NEXT_PUBLIC_BACKEND_URL=$NEXT_PUBLIC_BACKEND_URL
|
||||||
|
|
||||||
|
|
@ -62,4 +63,4 @@ EXPOSE 3000
|
||||||
ENV PORT=3000
|
ENV PORT=3000
|
||||||
ENV HOSTNAME="0.0.0.0"
|
ENV HOSTNAME="0.0.0.0"
|
||||||
|
|
||||||
CMD echo "NEXT_PUBLIC_BACKEND_URL = $NEXT_PUBLIC_BACKEND_URL" && node server.js
|
CMD node server.js
|
||||||
|
|
@ -1,9 +1,14 @@
|
||||||
import type { NextConfig } from "next";
|
import type { NextConfig } from "next";
|
||||||
|
|
||||||
|
const NEXT_PUBLIC_BACKEND_URL =
|
||||||
|
process.env.NODE_ENV === "production"
|
||||||
|
? process.env.NEXT_PUBLIC_BACKEND_URL || ""
|
||||||
|
: "http://localhost:4000";
|
||||||
|
|
||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
output: "standalone",
|
output: "standalone",
|
||||||
env: {
|
env: {
|
||||||
NEXT_PUBLIC_BACKEND_URL: process.env.NEXT_PUBLIC_BACKEND_URL,
|
NEXT_PUBLIC_BACKEND_URL: NEXT_PUBLIC_BACKEND_URL,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue