fix: resolve CORS issue for mask images by proxying through Next.js rewrites
This commit is contained in:
@@ -21,14 +21,15 @@ export default function DynamicLogo({
|
|||||||
}: DynamicLogoProps) {
|
}: DynamicLogoProps) {
|
||||||
|
|
||||||
const imageUrl = src.startsWith('/') ? openinaryLoader({ src, width: 800 }) : src;
|
const imageUrl = src.startsWith('/') ? openinaryLoader({ src, width: 800 }) : src;
|
||||||
|
const proxiedUrl = imageUrl.replace('https://media.ayris.tech', '/media-proxy');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={className}
|
className={className}
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: color,
|
backgroundColor: color,
|
||||||
maskImage: `url(${imageUrl})`,
|
maskImage: `url(${proxiedUrl})`,
|
||||||
WebkitMaskImage: `url(${imageUrl})`,
|
WebkitMaskImage: `url(${proxiedUrl})`,
|
||||||
maskRepeat: "no-repeat",
|
maskRepeat: "no-repeat",
|
||||||
maskPosition: "center",
|
maskPosition: "center",
|
||||||
maskSize: size,
|
maskSize: size,
|
||||||
|
|||||||
@@ -28,6 +28,14 @@ const nextConfig: NextConfig = {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
output: 'standalone',
|
output: 'standalone',
|
||||||
|
async rewrites() {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
source: '/media-proxy/:path*',
|
||||||
|
destination: 'https://media.ayris.tech/:path*',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default nextConfig;
|
export default nextConfig;
|
||||||
Reference in New Issue
Block a user