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

Tips for resolving the problem of Google Maps repeatedly appearing when utilizing the Auto-Loading feature

I need help understanding the issue that arose when loading the Google Maps API. "You have included the Google Maps API multiple times on this page. This may cause unexpected errors." This error occurred while attempting to automatically load the API. B ...

Tips for effectively handling numerous events from multiple Slickgrid instances on a single page

I'm encountering an issue with utilizing multiple Slickgrids on a single page. With the number of grids changing dynamically, I generate them within a JavaScript function and maintain them in a grid array as shown below. var columns = []; var options ...

A fresh PHP page escapes from the confines of an iframe and expands to occupy the entire

When calling a new url from inside an iframe, the goal is for the new url to break free from the confines of the iframe and appear full screen. The challenge lies in not having control over the call to the new php file, as it is initiated by a credit card ...

I am facing an issue with my react-app where it compiles successfully without any errors, but it is not rendering any elements

JavaScript file to run with npm start: import React from 'react'; import ReactDOM from 'react-dom'; import { BrowserRouter as Router } from 'react-router-dom'; import Routes from './routes'; ReactDOM.render( <R ...

Automatically compute and convert currency formats using JavaScript

May I ask again? Hopefully you understand. I am looking to automatically calculate with a money format. Here is a demo: https://jsfiddle.net/xp4ky2gg/ This is my code... HTML code <table style="width:100%"> ...

Passing Node.js MySQL query results to the next function within an async.waterfall workflow

In my node.js code using express, I have set up a route to request data from a mysql database. My goal is to pass the returned JSON in tabular form to another function to restructure it into a hierarchy type JSON. I have individually tested the script to ...

Get the file from the web browser

Hey there, greetings from my part of the world. I have some straightforward questions that I'm not sure have simple answers. Currently, I am working on a web application using the JSP/Servlet framework. In this app, users can download a flat text fil ...

What could be causing this error message to appear during my Storybook build process?

Recently, I made the leap of upgrading Storybook from V6.5.9 to V7.1.0 within a dynamic Next.js project. Surprisingly, everything seemed to be working fine until I attempted to build my storybook and encountered this perplexing error: ERR! => Failed to ...

Is there a way to transform this pledge back into a JSON array format?

My goal with this code is to retrieve a JSON array from my server. var students_list; const library_address = 'http://localhost:17330' async function fetchData(param1, param2) { if(param1 == 'getdata') { const response ...

Encountering difficulty running the server post integration of Sentry into a Next.js project

I found the documentation on how to add @sentry/nextjs to my project very helpful, which can be accessed at . I followed their instructions and added the configuration to my next.config.js file: const { withSentryConfig } = require('@sentry/nextjs&apo ...

What strategies can I implement to eliminate prop drilling when using a headless CMS? I believe that the Context API may have a negative

Looking to integrate a headless CMO into my NextJs app, specifically Sanity.io. SEO is a key consideration for the content. It seems that I can only fetch the data on a page-level using getStaticProps server-side for pre-rendering (crucial for SEO). Howev ...

Using Vue to implement a "v-model" on a custom component that incorporates the ace-editor

Snippet CustomEditor.vue: <template> <div class="custom-container"> <div class="custom-editor" ref="editor"></div> </div> </template> <script> import ace from 'ace-builds' import 'ace- ...

Using AJAX to send data to the server in jQuery

Currently, I have an AJAX request implemented on my webpage. I am exploring methods to detect when an AJAX call is initiated within the page using jQuery or JavaScript. Is there a way to identify or trigger a function upon the initiation of an AJAX reques ...

When attempting to use nodejs's collection.find() method with MongoDB, no response is received

I have been struggling to develop a node.js script that can retrieve only the records with a specific string key-value pair from a MongoDB collection containing around 30,000 documents. When I run this query on my MongoDB server, it gives me the exact res ...

Getting to a nested key in a JSON object with JavaScript: a step-by-step guide

Currently, I'm working with a JSON file and need to extract the fileName tag for use. { "dataset": { "private": false, "stdyDscr": { "citation": { "titlStmt": { "titl": "Smoke test", "IDNo": ...

The text box remains disabled even after clearing a correlated text box with Selenium WebDriver

My webpage has two text boxes: Name input box: <input type="text" onblur="matchUserName(true)" onkeyup="clearOther('txtUserName','txtUserID')" onkeydown="Search_OnKeyDown(event,this)" style="width: 250px; background-color: rgb(255, ...

Error: Unexpected token : encountered in jQuery ajax call

When creating a web page that requests remote data (json), using jQuery.ajax works well within the same domain. However, if the request is made from a different domain (e.g. localhost), browsers block it and display: No 'Access-Control-Allow-Or ...

Endless loops: How React JS components can render indefinitely

Every time I try to render a screen with the Bar component, it seems to get stuck in an infinite loop without even passing any data. I tested importing react-chartjs-2 and that worked fine, loading just once. However, the other bar chart keeps rendering co ...

What is the proper method for utilizing a conditional header in an rtk query?

How can I implement conditional header authentication using rtk query? I need to pass headers for all requests except refresh token, where headers should be empty. Is it possible to achieve this by setting a condition or using two separate fetchBaseQuery ...

Tips for reconstructing a path in Raphael JS

I am encountering a unique issue with my implementation of Raphael JS. Currently, I am working on drawing a donut element and seeking advice similar to the content found in this helpful link How to achieve 'donut holes' with paths in Raphael) var ...