Skip to content

chore: update image domain handling in next config - #1980

Merged
whitigol merged 4 commits into
mainfrom
chore/update-images-script
Feb 19, 2026
Merged

chore: update image domain handling in next config#1980
whitigol merged 4 commits into
mainfrom
chore/update-images-script

Conversation

@whitigol

@whitigol whitigol commented Feb 17, 2026

Copy link
Copy Markdown
Collaborator

Bug

Many users were experiencing images not loading. This was caused by Next.js deprecating images.domains in favor of images.remotePatterns. Our script was still written for the old API (adding a domain string via string replace), which no longer matches the current next.config.mjs structure and could break or fail to add the deployment origin.

Changes

  • scripts/create-images-domain.mjs

    • Switched from the deprecated domain-string approach to images.remotePatterns.
    • The script now injects a full pattern object (protocol, hostname, pathname: "**") derived from NEXT_PUBLIC_PROD_ORIGIN instead of appending a raw domain string.
    • Added idempotency: if the hostname is already in remotePatterns, the script exits without changing the config.
    • More robust parsing: locates the remotePatterns array and inserts the new entry before the closing ] instead of using a fragile string replace.
  • package.json

    • The build script now runs node scripts/create-images-domain.mjs before the Turbo build so the client’s Next config is updated with the correct image remote pattern for the deployment origin before building.
  • No breaking changes

  • Formatted with Prettier


@casperiv0, sorry for the @, I know you're a busy guy! But, I noticed in 1d8f6b5, it removed many parenthesized expressions that wrapped some nullish coalescing operators. I know it's best practice to wrap these in parenthesized expressions, but eslint/prettier complains about it and sees it as unnecessary. I briefly look through, and I personally don't see anything that could affect behavior, but I could be wrong. Let me know if you'd prefer to keep the parentheses and skip a full codebase format, or if you're okay with prettier removing them.

EDIT: I reverted the format commit resulting in eslint errors. Let me know if this is good to merge 🙂

@whitigol

Copy link
Copy Markdown
Collaborator Author

Ah, okay.. eslint complains about not having them. Go figure lol.

I'll get them placed back in.

This reverts commit 1d8f6b5.
@whitigol

Copy link
Copy Markdown
Collaborator Author

I’m going to go ahead and merge this. Casper, I saw your reaction, so I’m assuming/hoping that’s an approval? 😂

We can always revert if needed, but there have been a few requests for this fix. Let me know if anything needs to change.

@whitigol
whitigol merged commit d1106fe into main Feb 19, 2026
19 checks passed
@whitigol
whitigol deleted the chore/update-images-script branch February 19, 2026 16:57
@casperiv0

Copy link
Copy Markdown
Member

Thanks for this PR @whitigol! The code looks good, I'll make sure to test it out as well ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants