Skip to content

Commit

Permalink
[templates/nextjs] Add default image remotePatterns config for whitel…
Browse files Browse the repository at this point in the history
…isting remote image hostnames (#1732)

* add default image remotePatterns config for whitelisting remote image hostnames

* update changelog

* updated pattern to include lower edge environments
  • Loading branch information
yavorsk authored Feb 12, 2024
1 parent cc2bf32 commit dd978d7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Our versioning strategy is as follows:
* `[sitecore-jss-nextjs] [templates/nextjs-xmcloud]` SDK initialization rejections are now correctly handled. Errors should no longer occur after getSDK() promises resolve when they shouldn't (for example, getting Events SDK in development environment) ([#1712](https://github.com/Sitecore/jss/pull/1712) [#1715](https://github.com/Sitecore/jss/pull/1715) [#1716](https://github.com/Sitecore/jss/pull/1716))
* `[sitecore-jss-nextjs]` Remove custom loader function i.e. `sitecoreLoader` to enable NextImage to use built-in image optimization from vercel. ([#1726](https://github.com/Sitecore/jss/pull/1726))
* `[sitecore-jss-nextjs]` Fix redirects middleware for working with absolute url where is using site language context ([#1727](https://github.com/Sitecore/jss/pull/1727))
* `[templates/nextjs]` Add default image remotePatterns in next.config.js for whitelisting remote image hostnames so that can be served by the Next.js Image Optimization API ([#1732](https://github.com/Sitecore/jss/pull/1732))

### 🛠 Breaking Changes

Expand Down
13 changes: 13 additions & 0 deletions packages/create-sitecore-jss/src/templates/nextjs/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ const nextConfig = {
// Enable React Strict Mode
reactStrictMode: true,

// use this configuration to ensure that only images from the whitelisted domains
// can be served from the Next.js Image Optimization API
// see https://nextjs.org/docs/app/api-reference/components/image#remotepatterns
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'edge*.**',
port: '',
},
],
},

async rewrites() {
// When in connected mode we want to proxy Sitecore paths off to Sitecore
return [
Expand Down

0 comments on commit dd978d7

Please sign in to comment.