Next.js Discord

Discord Forum

Image error

Unanswered
ℛ𝒢𝓃 posted this in #help-forum
Open in Discord
Hiya there im on Nextjs V14 with chakra ui version 2.2.1 and I'm having some errors

So this is how im using the library rn https://cordx.lol/users/787241442770419722/hSRpizfL.png and btw the next/image is already import. but it gives me error - https://cordx.lol/users/787241442770419722/6n8o2Qrn.png

55 Replies

@ℛ𝒢𝓃 like?
read the docs
i have already configured everything
/**
 * NEXT.JS CONFIGURATION FILE
 * ==========================
 */

/** @type {import('next').NextConfig} */
const withPWA = require("next-pwa")({
  register: true,
  dest: "public",
  disable: process.env.NODE_ENV == "development",
});

const withBundleAnalyzer = require("@next/bundle-analyzer")({
  enabled: process.env.ANALYZE === "true" ? true : false,
  openAnalyzer: false,
});

const nextConfig = {
  async headers() {
    return [
      {
        source: "https://api.topiclist.xyz/:path*",
        headers: [
          { key: "Access-Control-Allow-Credentials", value: "true" },
          { key: "Access-Control-Allow-Origin", value: "*" },
          {
            key: "Access-Control-Allow-Methods",
            value: "GET,DELETE,PATCH,POST,PUT",
          },
          {
            key: "Access-Control-Allow-Headers",
            value:
              "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version",
          },
        ],
      },
    ];
  },
};

module.exports = nextConfig;

module.exports = withBundleAnalyzer(
  withPWA({
    swcMinify: true,
    compress: true,
    optimizeFonts: true,
    images: {
      formats: ["image/avif", "image/webp"],
      dangerouslyAllowSVG: true,
      unoptimized: true,
      remotePatterns: [
        {
          protocol: "https",
          hostname: "cdn.topiclist.xyz",
          pathname: "/images/**",
        },
        {
          protocol: "https",
          hostname: "beta.cordx.lol",
        },
      ],
      deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
      imageSizes: [16, 32, 48, 64, 96, 100, 128, 150, 256, 384],
    },
    env: {
      apiUrl: process.env.apiUrl,
    },
  }),
);
here is my full next.config.js
@ℛ𝒢𝓃 okay?
you sure you sent the correct screenshot? the error says it got 0pxas width
@ℛ𝒢𝓃 yes
try to remove the .next folder and start the dev server again
oki
hiya its fixed but now another error lol
it needs a numeric value
ohyeah sorry
set it to width={100} and height={100}
still the same
try to search for 0px in your file
its in many place lol
it should not interfear with the "https://cdn.topiclist.xyz/images/png/TopicList5.png"
@ℛ𝒢𝓃 https://cordx.lol/users/787241442770419722/cW3dnxZo.mp4
if they are props for an Image tag you have to fix them
please create a reproduction repository
thats a really hard task
@@ts-ignore https://nextjs-faq.com/minimal-reproduction-repository
my code is heavily dependend on other components
and that also depend on another and cycle goes on
@ℛ𝒢𝓃 and that also depend on another and cycle goes on
create a new repo with same nextjs version, setup the remote urls and add an image tag with same attributes
oki
@ℛ𝒢𝓃 https://github.com/Miya25/nextjs-5/tree/main
it works, there is smth wrong with the code you wrote then
if not
then I think you should create an issue on nextjs repo
@@ts-ignore i removed all things containing
so in theory
the error should be gone
then I think it is a bug with nextjs and you can create an issue
even thoall mention to the url
are gone