Runtime Error: Invalid source property detected - Firebase and Next.js collaboration issue

Currently, I am developing a Next.js application that retrieves data from a Firestore database. The database connection has been successfully established, and the data is populating the app. However, I am facing an issue with displaying the image {marketplaceTile}.

The images are stored in Firebase Storage and each document contains a string that represents the URL of the image.

In my next.config.js file, I have whitelisted the image source as follows:

module.exports = {
    images: {
        remotePatterns: [
            {
              protocol: 'https',
              hostname: 'firebasestorage.googleapis.com',
              port: '',
              pathname: '/**',
            },
          ],
    },
};

Despite this configuration, I am encountering an error message stating: "Unhandled Runtime Error Error: Invalid src prop (URL) on next/image, hostname "firebasestorage.googleapis.com" is not configured under images in your next.config.js" For more details, refer to: https://nextjs.org/docs/messages/next-image-unconfigured-host"

The connection to the database is made through this code snippet:

useEffect(() => {
        ;(async () => {
            const colRef = collection(db, 'products')
            const snapshots = await getDocs(colRef)
            const docs = snapshots.docs.map((doc) => {
                const data = doc.data()
                data.id = doc.id
                return data
            })

            setProducts(docs)

            console.log(docs)
        })()
    }, [])

Additionally, here is a snippet of my Products component:

function Product({ id, title, price, description, category, marketplaceTile }) {
  const dispatch = useDispatch();

  const addItemToBasket = () => {
    const product = {
      id,
      title,
      price,
      description,
      category,
      gameCover,
      marketplaceTile,
      developer,
    };
    console.log(product)

    //Send the product as an action to the REDUX store (Basket Slice)
    dispatch(addToBasket(product));
  };

  return (
    <div>
<Image src={marketplaceTile} height={200} width={200} className="mx-auto object-contain" alt="Product Image"/>

      <h4 className="my-3 text-gray">{title}</h4>
</div>

The variable marketplaceTile contains the reference to the image I am trying to display. Any guidance or assistance on resolving this issue would be greatly appreciated. Thank you!

Answer №1

It appears that the pathname for the images has not been included in your code

/** @type {import('next').NextConfig} */
module.exports = {
  images: {
    formats: ['image/avif', 'image/webp'],
    remotePatterns: [
      {
        protocol: 'https',
        hostname: 'firebasestorage.googleapis.com',
        port: '',
        pathname: '/image/upload/**',
      },
    ],
  },
}

Make sure the image URL is not null and refer to this Github link for additional assistance.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issue with Checkbox Functionality Between Parent and Child Components in React.js

In the main component, I have four checkboxes. My goal is to display a value from a function in the child component based on whether each checkbox is checked or not. export default class App extends Component { constructor(props) { super(props); ...

The object's type remains a mystery

While working on implementing jwt authentication in Ionic, React with TypeScript, I faced a typescript error when trying to add a check in my App.tsx file after successful implementation. The error stated: Object is of type 'unknown' Below is ...

What is the process for submitting information to my Next.js API endpoint?

As part of my learning journey with Next.js, I am currently developing a test e-commerce website. To enhance the functionality, I am integrating a checkout system using Stripe. Initially, I was able to successfully implement the checkout feature with stati ...

Enable automatic full-screen mode on Google Chrome upon page load

I would greatly appreciate it if you could provide an answer to this question, even if it is marked as a duplicate. I have tried various solutions and sought help, but unfortunately, nothing seems to be working for me... What I really need is for the brow ...

Creating TypeScript domain objects from JSON data received from a server within an Angular app

I am facing a common challenge in Angular / Typescript / JavaScript. I have created a simple class with fields and methods: class Rectangle { width: number; height: number; area(): number { return this.width * this.height; } } Next, I have a ...

Encountering an issue when retrieving data from Firebase Firestore in NEXT.JS with Firebase SDK Firebase v9 results in an error message

Greetings! I am currently trying to retrieve data from Firebase Firestore by following a tutorial on Firebase v9. However, I encountered an error message that says "FIRESTORE (9.8.4) INTERNAL ASSERTION FAILED: Unexpected state". Below is the code snippet: ...

Is it possible to nest v-for directives within a component file?

Even after going through the VueJS tutorials multiple times, I am still unable to find a solution to this problem. My issue revolves around displaying a list of lists using accordions, which is supposed to work smoothly with vue-strap components. For exa ...

Expanding functionality: Steps to integrating a new endpoint into your AWS Amplify Express Server

I have created a REST express server using Amplify. Attempted to include two additional endpoints: // incorporating serverless express app.post('/myendpoint', function(req, res) { console.log('body: ', req.body) res.json(req.body) ...

Can you help me understand how to create a JSON file using webpack?

My goal is to create a customized `manifest.json` file for Chrome extensions in a more efficient, programmatic manner. Utilizing npm for dependency management, I've noticed that the `package.json` shares key fields with the `manifest.json`, such as "n ...

Exploring the capabilities of HTML5's file API along with Octokit.js to work with

I have been trying to create a form that allows users to upload binary data to GitHub using octokit.js. However, every time I attempt to do so, the data ends up corrupted on the GitHub side. Here is a minimal working example: http://jsfiddle.net/keddie/7r ...

Problem: The variable "$" is not defined in angular datatables causing a ReferenceError

Trying to implement Paging and sorting in my table, but encountered an error even after following all the steps mentioned here: . Tried troubleshooting the issue with no success. Ensured that all dependencies were installed properly. Below is the compo ...

The generateMetadata function in NextJS is not returning the expected parameters

When using generateMetadata, the function provides params just like a page. In this case, I am trying to retrieve metadata from my CMS by utilizing lang and slug from these params. However, they always seem to be undefined and revert back to their defaults ...

Exploring the power of Cucumber, Ruby, Capybara, and Selenium: Enhancing the 'visit' method to handle dynamic content delays

For weeks now, I've been dealing with an issue that seems to have no solution found online... like waiting for ajax, etc... Check out the versions of gems: capybara (2.10.1, 2.7.1) selenium-webdriver (3.0.1, 3.0.0) rspec (3.5.0) running ruby 2.2.5 ...

Is there a way to access and update my users' Google Calendar Events through my NextJS application?

Currently, I am working on a NextJS platform where I am trying to integrate Google Calendar functionality. My goal is to access my users' calendar events and also have the ability to add events to their calendars. To achieve this, I have already set ...

A step-by-step guide on integrating Firebase authentication with a Next.js application

I'm facing difficulties when trying to create a next.js app with express and firebase-authentication. I'm also unsure about the role of redux in this setup. Can anyone please assist me with this or recommend some tutorials? I've found that t ...

I'm perplexed by setting up Node.js in order to work with Angular.js

Currently following the Angular tutorial provided at https://docs.angularjs.org/tutorial, but I'm encountering confusion with the Node.js installation. Having already installed node globally on my Mac, the tutorial mentions: The tutorial instructio ...

Is there a way to use a POST request and Mongoose in Express to add a new object?

I am struggling to figure out how to use .Router() for creating a POST request route. I have only worked with getById before. Can someone help me create a route for POST requests? ./generalRepository.js function Repository() {} Repository.prototype.getB ...

I am currently utilizing react-admin, however, I am encountering an issue with the heavy build causing errors

Currently, I am working on developing the frontend using react-admin. Initially, I intended to utilize NextJS and found a helpful reference article. Reference: When attempting to run next dev, everything worked smoothly without any errors. However, when ...

Split total based on checkboxes toggled with JavaScript

I'm facing a challenge. I have a total sum of donations collected, for example, 10€. Additionally, there are various NGOs that one can select to donate to. Individuals have the option to toggle on/off which NGO's they wish to contribute toward ...

Do not proceed with the form submission if the fields are left blank

I am facing a challenge with organizing two sets of data, "heat" and "cold", obtained from an external provider. The data is messy and I have trimmed down the code to focus on the main issue at hand. Both "heat" and "cold" have properties that users need t ...