Next.js Discord

Discord Forum

Why does the element display http

Answered
Air Penguin posted this in #help-forum
Open in Discord
The next/image assigned src is https, and http is displayed on the element, with no redirection when loaded
Answered by iyxan23
im guessing the url you got from contentItem.image could be http
View full answer

50 Replies

also is this running in prod or is it a dev server?
i suspect next would use to http instead of https on a dev environment, but that's just a guess
this running in prod and I can make sure that the interface returns https
I also configured remotePatterns in next.config.js
that's odd, have you tried doing a simple curl on the site and verify that it uses http from the source?
@Air Penguin The next/image assigned src is https, and http is displayed on the element, with no redirection when loaded
from what i could tell in this screenshot, it seemed like chrome is actually sourcing the image from the https url despite the actual src being http; it could be either from chrome doing it by itself, or from an http upgrade from that server's side

have you checked the networks tab to verify that it did use https to fetch the image?
yeah networks use https to get this image
This is very strange
Using curl at the terminal will display 301, but the browser will not, it will directly load the https image, although the src display http
oh right it redirected to the https version
humm but the issue is that next's image uses http right?
since you supplied an onLoad parameter to the component, the loadedCb function perhaps did something that makes next's image use http to fetch the image
oh sorry i confused onLoad as loader 😅
I recorded a video to show the browser loading the image
very, very, very strange:lolsob:
indeed
i had just noticed, my prod next site uses a /_next/image/... as src instead of just the url right away?
and it has srcset on
oh did you use the wrong component?
next's image is imported from next/image, could you make sure of that?
@iyxan23 next's image is imported from `next/image`, could you make sure of that?
yeah,Yes, I used import Image from 'next/image';
@iyxan23 i had just noticed, my prod next site uses a `/_next/image/...` as src instead of just the url right away?
i set unoptimized: true,so instead of using optimized image addresses,
oh right
I'm trying to console the data to see if something has changed it, although it might not, right
yeah from what i could read on next's source, the image's src is passed right through without modification at all when unoptimized is true
fine, I'll check it later.
I would like to add one thing,
My picture is now provided by two services, another service https://ws-cms.justfit.app is no problem
that's funny.
im guessing the url you got from contentItem.image could be http
Answer
maybe try contentItem.image.replace("http", "https") just to check lol
yeah, really a good way to debug
I found out why ...this has to do with my cms S3 plugins...lol
It was closed. Just turn it on
oh cool 👍
didn't know you were using a CMS
tho it's kinda odd that next's remoteImages didn't catch the http
maybe because you enabled the unoptimized option
yes, I did omit this part of the information, I am very sorry
no prob, as long as it works, it works :sunglasses_1:
thank you lol
@Air Penguin thank you lol
Dont forget to mark an answer so the thread gets closed out 🙂
I tried it. How do I label the answer:lolsob:
right click > apps > mark solution
“Thank you lol” is not the answer