@@ -5,26 +5,6 @@ import createNextIntlPlugin from "next-intl/plugin";
5
5
6
6
const withNextIntl = createNextIntlPlugin ( ) ;
7
7
8
- const imageHostnameInternal = String (
9
- process . env . DRUPAL_BASE_URL_INTERNAL_IMAGES ,
10
- ) . split ( "://" ) ;
11
-
12
- if ( imageHostnameInternal . length < 2 ) {
13
- throw new Error (
14
- "Invalid DRUPAL_BASE_URL_INTERNAL_IMAGES. Expected a valid URL with protocol and hostname." ,
15
- ) ;
16
- }
17
-
18
- const imageHostnameExternal = String (
19
- process . env . NEXT_PUBLIC_DRUPAL_BASE_URL ,
20
- ) . split ( "://" ) ;
21
-
22
- if ( imageHostnameExternal . length < 2 ) {
23
- throw new Error (
24
- "Invalid NEXT_PUBLIC_DRUPAL_BASE_URL. Expected a valid URL with protocol and hostname." ,
25
- ) ;
26
- }
27
-
28
8
/** @type {import('next').NextConfig } */
29
9
const nextConfig = {
30
10
reactStrictMode : true ,
@@ -40,17 +20,19 @@ const nextConfig = {
40
20
41
21
images : {
42
22
remotePatterns : [
43
- {
44
- protocol : imageHostnameExternal [ 0 ] === "https" ? "https" : "http" ,
45
- hostname : imageHostnameExternal [ 1 ] ,
23
+ process . env . DRUPAL_BASE_URL_INTERNAL_IMAGES ,
24
+ process . env . NEXT_PUBLIC_DRUPAL_BASE_URL ,
25
+ ] . map ( ( url = "" ) => {
26
+ const [ protocol , hostname ] = url . split ( "://" ) ;
27
+ if ( ! hostname || ( protocol !== "https" && protocol !== "http" ) ) {
28
+ throw new Error ( `Invalid images URL "${ url } " in next.config.ts` ) ;
29
+ }
30
+ return {
31
+ protocol,
32
+ hostname,
46
33
pathname : "**" ,
47
- } ,
48
- {
49
- protocol : imageHostnameInternal [ 0 ] === "https" ? "https" : "http" ,
50
- hostname : imageHostnameInternal [ 1 ] ,
51
- pathname : "**" ,
52
- } ,
53
- ] ,
34
+ } ;
35
+ } ) ,
54
36
} ,
55
37
56
38
experimental : {
0 commit comments