diff --git a/frontend/apply/src/app/about/page.tsx b/frontend/apply/src/app/about/page.tsx
index eb930a5..3211849 100644
--- a/frontend/apply/src/app/about/page.tsx
+++ b/frontend/apply/src/app/about/page.tsx
@@ -2,7 +2,6 @@
import { useTranslation } from "react-i18next";
import Image from "next/image";
-import { getImageUrl } from "@/utils/imageUrl";
export default function About() {
const { t } = useTranslation();
@@ -11,7 +10,7 @@ export default function About() {
{t("aboutPage.title")}
{t("aboutPage.introText")}
`. The browser never
+ * loads it directly — it only sees `/_next/image?url=…`. So the URL
+ * must be reachable from the Next.js **server**.
+ *
+ * Docker dev → http://backend:8000 (always correct inside Docker)
+ * Production → window.location.origin (nginx proxies /media/ to Django)
+ *
+ * Set NEXT_PUBLIC_API_URL at **build time** to an absolute URL to override
+ * the Docker default (e.g. for local dev: http://localhost:8000/api).
*/
export function getImageUrl(url: string): string {
if (url.startsWith("http://") || url.startsWith("https://")) {
return url;
}
- const apiUrl = process.env.NEXT_PUBLIC_API_URL;
+ // Paths that don't start with /media/ are local Next.js files
+ if (!url.startsWith("/media/")) {
+ return url;
+ }
- // 1. Absolute env var – derive backend base from it
+ // Build-time env var override (NEXT_PUBLIC_* are inlined at build time)
+ const apiUrl = process.env.NEXT_PUBLIC_API_URL;
if (apiUrl && (apiUrl.startsWith("http://") || apiUrl.startsWith("https://"))) {
return `${apiUrl.replace(/\/api\/?$/, "")}${url}`;
}
- // 2. Docker Compose dev – always use the internal Docker hostname.
- // next/image fetches images on the server, so the browser never
- // needs to resolve "backend". Both SSR and client must return the
- // same URL to avoid a hydration mismatch.
+ // Client-side
+ if (typeof window !== "undefined") {
+ // Docker dev – don't use localhost:3000, the Next.js server needs
+ // to reach the backend container at backend:8000
+ if (window.location.hostname === "localhost") {
+ return `http://backend:8000${url}`;
+ }
+ // Production – nginx proxies /media/ to Django on the same domain
+ return `${window.location.origin}${url}`;
+ }
+
+ // SSR default: Docker Compose (Next.js server reaches backend:8000)
return `http://backend:8000${url}`;
}