Wildcard Image Domain on Next.js
Warning
Over a year old. May be outdated
- Next.js
Save the following as pages/api/imageProxy.ts
And use it as:
Backlinks1
221110Warning
yarn add @blazity/next-image-proxySave 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}`}