Wildcard Image Domain on Next.js
yarn add @blazity/next-image-proxy
Save the following as pages/api/imageProxy.ts
import { withImageProxy } from '@blazity/next-image-proxy'
export default withImageProxy({
whitelistedPatterns: [/^https?:\/\/(.*).mydomain.com/],
})
And use it as:
src={`/api/imageProxy?imageUrl=${actualImageUrl}`}