Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ NEXT_PUBLIC_AVATARS_API_URL=http://localhost:8001
NEXT_PUBLIC_AUTH_APP_URL=http://localhost:5173
NEXT_PUBLIC_AUTH_API_URL=http://localhost:8002

AWS_S3_ENDPOINT_URL=http://localhost:9000
AWS_S3_ENDPOINT_URLS=http://localhost:9000
AVATARS_API_URL=http://localhost:8001
31 changes: 19 additions & 12 deletions frontend/next.config.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
import type { NextConfig } from "next";
import type { RemotePattern } from "next/dist/shared/lib/image-config";

function getRemotePattern(url?: string): RemotePattern {
if (!url) throw new Error(`Not a valid URL: ${url}`);
function getRemotePattern(url?: string): RemotePattern | null {
if (!url) return null;

const u = new URL(url);
return {
protocol: u.protocol.includes("s") ? "https" : "http",
hostname: u.hostname,
port: u.port,
pathname: "/**",
};
try {
const u = new URL(url);
return {
protocol: u.protocol.includes("s") ? "https" : "http",
hostname: u.hostname,
port: u.port,
pathname: "/**",
};
} catch {
return null;
}
}

const s3Urls = process.env.AWS_S3_ENDPOINT_URLS?.split(",") || [];
const avatarsUrl = process.env.AVATARS_API_URL;

const nextConfig: NextConfig = {
devIndicators: false,
images: {
remotePatterns: [
getRemotePattern(process.env.AWS_S3_ENDPOINT_URL),
getRemotePattern(process.env.AVATARS_API_URL),
],
...s3Urls.map((url) => getRemotePattern(url.trim())),
getRemotePattern(avatarsUrl),
].filter((p): p is RemotePattern => p !== null),
},
};

Expand Down
Loading