-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Closed
Labels
bugIssue was opened via the bug report template.Issue was opened via the bug report template.
Description
What version of Next.js are you using?
11.0.1
What version of Node.js are you using?
14.16.1
What browser are you using?
Brave, Chrome,
What operating system are you using?
macOS
How are you deploying your application?
Vercel
Describe the Bug
We created our own components library and published it to the GitLab package registry.
Our Product Cover component is based on next/image. It works fine on a storybook with unoptimized props.
But I can't use <Cover/> component on the NextJS application because of an error.
Error: Invalid src prop (https://cdn.esan.mn/cover/6sd8knfnvus5.jpg) on `next/image`, hostname "cdn.esan.mn" is not configured under images in your `next.config.js`
Here is my component source:
import React from "react";
import Image from "next/image";
import { Box, BoxProps } from "@chakra-ui/react";
export interface CoverProps extends BoxProps {
src: string;
previewUrl: string;
alt: string;
imageProps?: {
width: number;
height: number;
};
}
export const Cover: React.FC<CoverProps> = ({
src,
previewUrl,
alt,
borderRadius = "xs",
imageProps = {
width: 550,
height: 825,
},
...otherProps
}) => {
return (
<Box
position="relative"
boxShadow="0px 8px 18px rgba(17, 17, 17, 0.04)"
overflow="hidden"
borderRadius={borderRadius}
{...otherProps}
>
<Image
{...imageProps}
layout="responsive"
src={src}
alt={alt}
placeholder="blur"
blurDataURL={previewUrl}
/>
</Box>
);
};In my application, I installed a component library, use it in ProductList component.
<ContentCard
alt={content.name}
previewUrl={previewUrl}
src={url}
/>Here is next.config.js:
const nextConfig = {
poweredByHeader: false,
target: "serverless",
webpack5: false,
images: {
domains: ["cdn.esan.mn", "image.esan.mn", "cdn.elibrary.mn"],
},
...
}
module.exports = withPlugins(
[
...
],
nextConfig
);Expected Behavior
TDB
To Reproduce
TDB
Metadata
Metadata
Assignees
Labels
bugIssue was opened via the bug report template.Issue was opened via the bug report template.