Fetching Image URL from firebase
Unanswered
Bigeye tuna posted this in #help-forum
Bigeye tunaOP
So, I've been googling around like a crazy man and read docs but... somehow I don't get it working. I have an image stored in my firebase storage as mocked up, my <Image> code:
This works perfectly fine locally, but when I deploy and in production mode it gets 404 error. The url is: https://firebasestorage.googleapis.com/v0/b/web-blogapp.appspot.com/o/cutedog.jfif?alt=media but error says GET 404 not found with link:
https://web-blogapp.web.app/_next/image?url=https%3A%2F%2Ffirebasestorage.googleapis.com%2Fv0%2Fb%2Fweb-blogapp.appspot.com%2Fo%2Fcutedog.jfif%3Falt%3Dmedia&w=640&q=75
my next.config.js:
If I replace nextjs inbuilt Image to regular <img> it works. Any idea why this occurs?
{blog.imageUrl && (
<div className="pb-[56.25%] w-full relative">
<Image
src={blog.imageUrl}
alt={blog.title}
sizes="(max-width: 768px) 100vw, 33vw"
fill="true"
style={{ objectFit: "cover" }}
/>
</div>
)}This works perfectly fine locally, but when I deploy and in production mode it gets 404 error. The url is: https://firebasestorage.googleapis.com/v0/b/web-blogapp.appspot.com/o/cutedog.jfif?alt=media but error says GET 404 not found with link:
https://web-blogapp.web.app/_next/image?url=https%3A%2F%2Ffirebasestorage.googleapis.com%2Fv0%2Fb%2Fweb-blogapp.appspot.com%2Fo%2Fcutedog.jfif%3Falt%3Dmedia&w=640&q=75
my next.config.js:
/** @type {import('next').NextConfig} */
const nextConfig = {
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'firebasestorage.googleapis.com',
port: '',
},
],
},
};
export default nextConfig;If I replace nextjs inbuilt Image to regular <img> it works. Any idea why this occurs?
3 Replies
@Bigeye tunaThis sounds like an issue somewhere else, perhaps your middleware? When the image optimizing path has an issue with the image url you are trying to optimize, it doesn't return a 404, it returns a 400 I believe
Bigeye tunaOP
Hmmm that’s strange, ill make some research tomorrow, my eyes are tired atm lol
Bigeye tunaOP
Found this:
https://stackoverflow.com/questions/60125925/cannot-render-images-in-next-js-with-example-with-firebase-hosting-and-typescri
https://stackoverflow.com/questions/60125925/cannot-render-images-in-next-js-with-example-with-firebase-hosting-and-typescri
images: { unoptimized: true } solved my issue but sadly Image isnt being optimized then, but I guess I can dive into this issue later since one of answers from that stackoverflow said: It seems that Firebase Hosting, in conjunction with Next.js and TypeScript, may encounter issues with rendering images due to some experimental features. I suspect nextjs with firebase is still in experimental phase.