Skip to content

Commit 22df719

Browse files
add mapping from string urls to URL objects
1 parent d4d116a commit 22df719

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

apps/site/next.image.config.mjs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@ import {
33
OPEN_NEXT_CLOUDFLARE,
44
} from './next.constants.mjs';
55

6+
const remotePatterns = [
7+
'https://avatars.githubusercontent.com/**',
8+
'https://bestpractices.coreinfrastructure.org/**',
9+
'https://raw.githubusercontent.com/nodejs/**',
10+
'https://user-images.githubusercontent.com/**',
11+
'https://website-assets.oramasearch.com/**',
12+
];
13+
614
export const getImagesConfig = () => {
715
if (OPEN_NEXT_CLOUDFLARE) {
816
// If we're building for the Cloudflare deployment we want to use the custom cloudflare image loader
917
//
1018
// Important: The custom loader ignores `remotePatterns` as those are configured as allowed source origins
1119
// (https://developers.cloudflare.com/images/transform-images/sources/)
12-
// in the Cloudflare dashboard itself instead (to the exact same values present in `remotePatterns` below).
20+
// in the Cloudflare dashboard itself instead (to the exact same values present in `remotePatterns` above).
1321
//
1422
return {
1523
loader: 'custom',
@@ -22,12 +30,6 @@ export const getImagesConfig = () => {
2230
unoptimized: ENABLE_STATIC_EXPORT,
2331
// We add it to the remote pattern for the static images we use from multiple sources
2432
// to be marked as safe sources (these come from Markdown files)
25-
remotePatterns: [
26-
new URL('https://avatars.githubusercontent.com/**'),
27-
new URL('https://bestpractices.coreinfrastructure.org/**'),
28-
new URL('https://raw.githubusercontent.com/nodejs/**'),
29-
new URL('https://user-images.githubusercontent.com/**'),
30-
new URL('https://website-assets.oramasearch.com/**'),
31-
],
33+
remotePatterns: remotePatterns.map(url => new URL(url)),
3234
};
3335
};

0 commit comments

Comments
 (0)