-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
43 lines (38 loc) · 1.08 KB
/
next.config.ts
File metadata and controls
43 lines (38 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import type { NextConfig } from "next";
/**
* Génère les patterns d'images autorisées depuis les variables d'environnement.
* Utilise NEXT_PUBLIC_WORDPRESS_API_URL pour autoriser les images WordPress.
*/
const getWordPressImagePatterns = () => {
const patterns: { protocol: 'https' | 'http'; hostname: string }[] = [];
// Extraire le hostname depuis NEXT_PUBLIC_WORDPRESS_API_URL
if (process.env.NEXT_PUBLIC_WORDPRESS_API_URL) {
try {
const url = new URL(process.env.NEXT_PUBLIC_WORDPRESS_API_URL);
patterns.push({
protocol: url.protocol.replace(':', '') as 'https' | 'http',
hostname: url.hostname,
});
} catch {
console.warn('Invalid NEXT_PUBLIC_WORDPRESS_API_URL format');
}
}
return patterns;
};
const nextConfig: NextConfig = {
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'secure.gravatar.com',
},
{
protocol: 'https',
hostname: 'github.com',
},
...getWordPressImagePatterns(),
],
},
output: "standalone",
};
export default nextConfig;