CDN calls intermittently fail in deploy preview

@dojosch, have you seen amy improvements on your site?

@hrishikesh images are broken again this morning https://techinterview.coach/cdn/480/logo-tech-light.png for https://techinterview.coach/images/logo-tech-light.png

current redirects:

[[redirects]] # Serve a full size version from = "/cdn/full/*" to = "/.netlify/images?url=/images/:splat" status = 200 [[redirects]] # ...or serve a resized version from = "/cdn/:width/*" to = "/.netlify/images?url=/images/:splat&width=:width" status = 200 

getting

# Access to techinterview.coach was denied You don't have authorisation to view this page. HTTP ERROR 403 

https://techinterview.coach/.netlify/images?url=/images/logo-tech-light.png fails as well

as does

https://production--techinterviewcoach.netlify.app/.netlify/images?url=/images/logo-tech-light.png

@techinterview-coach The redirects don’t seem to be involved.

As the same error is seen when the URL is accessed without them:
https://techinterview.coach/.netlify/images?url=/images/logo-tech-light.png&width=480

Something odd that I’ve noticed, and may provide an avenue for you to investigate:

Your image URL has the following response headers:

Checking the developers.netlify guide that you referenced, a sample image is:
https://developers.netlify.com/images/600/guides/2024-02-29-how-to-serve-optimized-images-using-netlify-image-cdn/blue-flowers.jpg

So the direct URL for that without the redirect is:
https://developers.netlify.com/.netlify/images?url=/images/guides/2024-02-29-how-to-serve-optimized-images-using-netlify-image-cdn/blue-flowers.jpg&width=600

The response headers for that image are:

Your one says Server: cloudflare
The demo one says Server: Netlify

Hi @nathanmartin, yes the website sits behind cloudflare (I have some issues with bot attacks) and it’s been sitting behind it for the last year and a half, maybe two. I’ve looked into Cloudflare just in case and I can’t see anything wrong. Disabling/bypassing doesn’t seem to help.

Nothing has changed on my side on the website in the last 24h and yet the page is broken.

This request is also failing (error 400) despite having server: Netlify not server: cloudflare https://production--techinterviewcoach.netlify.app/.netlify/images?url=/images/logo-tech-light.png so I don’t think that’s the cause or a worthwhile investigation path.

Best to eliminate as many pieces as possible though.

The above URL is more likely to get them to spot what may be wrong and investigate than something behind cloudflare, when they tend to recommend not doing that.

In the case of the URL you supplied above, I saw it work on an edge hit:

But fail on an edge miss:

Thank you for that. What can cause the hit or miss?

Thanks, I was on mobile I should have searched before asking.

Based that + the above, it seems the issue is somewhere on Netlify’s side… altough I had a look at Netlify’s CDN playground though and seems ok https://image-cdn-playground.netlify.app/

@techinterview-coach Earlier in this thread it was raised that you had an edge function that was running on all routes, and you never responded to say if that was removed/adjusted or not.

I’m not sure if it’s protected in some way, (having literally never worked with any of this myself), but is it possible that your edge function is executing on the /.netlify routes?

@nathanmartin I disabled that redirect, replacing the /images/:width and /images/full redirects with

[[redirects]] # Serve a full size version from = "/cdn/full/*" to = "/.netlify/images?url=/images/:splat" status = 200 [[redirects]] # ...or serve a resized version from = "/cdn/:width/*" to = "/.netlify/images?url=/images/:splat&width=:width" status = 200 

to make them non over-lapping, just in case that was the issue.

Some images (about 30%) started to get cache hits and were working for a bit, now they’re failing again.

@techinterview-coach I’m more concerned about why the direct requests aren’t working, as I believe that they should never fail.

Yeah. I’ve just modified

[[edge_functions]] path = "/*" function = "localized-content" 

adding

 excludedPath = "/images/*" 

(the other change that @hrishikesh suggested)

It’s rolling out to production now (hadn’t got around to it yet). Not sure if it’ll make a difference, let’s see.

edit: Looks fixed now.

1 Like

glad to hear you were able to fix the issue.

Hi, do we know exactly what had broken my images? Was it the edge function or the way the cdn redirect had been written before?

@techinterview-coach I may be wrong, but as I understand it, it was your edge function running on requests being made to the paths of your static images, the files in /images/*, that caused your issue.

It also explains why the direct URL was broken:
https://techinterview.coach/.netlify/images?url=/images/logo-tech-light.png&width=480

As while your edge function wasn’t necessarily running on the .netlify/ route:
https://techinterview.coach/.netlify/

The images API can ingest images from multiple sources:
https://docs.netlify.com/image-cdn/overview/#source

So when it was reaching out to get the original image for transformation:
url=/images/logo-tech-light.png&width=480

It was probably receiving it’s response via your edge function.

The biggest indication that was the cause of the issue, is that once you excluded that folder from being handled by your edge function, suddenly it all worked everywhere, both via redirect and directly.

That feels right but it doesn’t explain why things worked for months and then, suddenly, didn’t =(

Thanks though, much appreciate your time and help!

Just in now… I re-enabled cloudflare (no changes to my configuration, which worked for months) and I am getting 403 denied errors again; maybe the problem wasn’t just the edge function…

a few mins later and a few of the images loaded for me on the homepage… but still look broadly broken on other page or if accessed @ Free Geo Browse: Check Your Website from Different Countries

Disabling cloudflare brought the images back.

^ I previously pointed out it was behind cloudflare, and suggested that it might be part of the issue.

^ You were adamant that cloudflare had no impact, so I didn’t press it.

It’s entirely possible for there to be multiple issues.

What’s the latest set of URLs that are returning a 403?