Wildcard Image Domain on Next.js

Wildcard Image Domain on Next.js

text
yarn add @blazity/next-image-proxy

Save the following as pages/api/imageProxy.ts

ts
import { withImageProxy } from "@blazity/next-image-proxy";

export default withImageProxy({
  whitelistedPatterns: [/^https?:\/\/(.*).mydomain.com/],
});

And use it as:

tsx
src={`/api/imageProxy?imageUrl=${actualImageUrl}`}
Backlinks1