@@ -8,6 +8,45 @@ import {
88} from './next.constants.mjs' ;
99import { redirects , rewrites } from './next.rewrites.mjs' ;
1010
11+ const getImagesConfig = ( ) => {
12+ if ( OPEN_NEXT_CLOUDFLARE ) {
13+ // If we're building for the Cloudflare deployment we want to use the custom cloudflare image loader
14+ //
15+ // Important: The custom loader ignores `remotePatterns` as those are configured as allowed source origins
16+ // (https://developers.cloudflare.com/images/transform-images/sources/)
17+ // in the Cloudflare dashboard itself instead (to the exact same values present in `remotePatterns` below).
18+ //
19+ return {
20+ loader : 'custom' ,
21+ loaderFile : './cloudflare/image-loader.ts' ,
22+ } ;
23+ }
24+
25+ return {
26+ // We disable image optimisation during static export builds
27+ unoptimized : ENABLE_STATIC_EXPORT ,
28+ // We add it to the remote pattern for the static images we use from multiple sources
29+ // to be marked as safe sources (these come from Markdown files)
30+ remotePatterns : [
31+ new URL ( 'https://avatars.githubusercontent.com/**' ) ,
32+ new URL ( 'https://bestpractices.coreinfrastructure.org/**' ) ,
33+ new URL ( 'https://raw.githubusercontent.com/nodejs/**' ) ,
34+ new URL ( 'https://user-images.githubusercontent.com/**' ) ,
35+ new URL ( 'https://website-assets.oramasearch.com/**' ) ,
36+ ] ,
37+ } ;
38+ } ;
39+
40+ const getDeploymentId = async ( ) => {
41+ if ( OPEN_NEXT_CLOUDFLARE ) {
42+ // If we're building for the Cloudflare deployment we want to set
43+ // an appropriate deploymentId (needed for skew protection)
44+ return ( await import ( '@opennextjs/cloudflare' ) ) . getDeploymentId ( ) ;
45+ }
46+
47+ return undefined ;
48+ } ;
49+
1150/** @type {import('next').NextConfig } */
1251const nextConfig = {
1352 allowedDevOrigins : [ '10.1.1.232' ] ,
@@ -76,44 +115,5 @@ const nextConfig = {
76115 deploymentId : await getDeploymentId ( ) ,
77116} ;
78117
79- function getImagesConfig ( ) {
80- if ( OPEN_NEXT_CLOUDFLARE ) {
81- // If we're building for the Cloudflare deployment we want to use the custom cloudflare image loader
82- //
83- // Important: The custom loader ignores `remotePatterns` as those are configured as allowed source origins
84- // (https://developers.cloudflare.com/images/transform-images/sources/)
85- // in the Cloudflare dashboard itself instead (to the exact same values present in `remotePatterns` below).
86- //
87- return {
88- loader : 'custom' ,
89- loaderFile : './cloudflare/image-loader.ts' ,
90- } ;
91- }
92-
93- return {
94- // We disable image optimisation during static export builds
95- unoptimized : ENABLE_STATIC_EXPORT ,
96- // We add it to the remote pattern for the static images we use from multiple sources
97- // to be marked as safe sources (these come from Markdown files)
98- remotePatterns : [
99- new URL ( 'https://avatars.githubusercontent.com/**' ) ,
100- new URL ( 'https://bestpractices.coreinfrastructure.org/**' ) ,
101- new URL ( 'https://raw.githubusercontent.com/nodejs/**' ) ,
102- new URL ( 'https://user-images.githubusercontent.com/**' ) ,
103- new URL ( 'https://website-assets.oramasearch.com/**' ) ,
104- ] ,
105- } ;
106- }
107-
108- async function getDeploymentId ( ) {
109- if ( OPEN_NEXT_CLOUDFLARE ) {
110- // If we're building for the Cloudflare deployment we want to set
111- // an appropriate deploymentId (needed for skew protection)
112- return ( await import ( '@opennextjs/cloudflare' ) ) . getDeploymentId ( ) ;
113- }
114-
115- return undefined ;
116- }
117-
118118const withNextIntl = createNextIntlPlugin ( './i18n.tsx' ) ;
119119export default withNextIntl ( nextConfig ) ;
0 commit comments