DMarby / picsum-photos

Lorem Ipsum... but for photos.
https://picsum.photos
MIT License
2.2k stars 152 forks source link

Getting cloud flare error code 1020 #101

Closed HolgerGottChristensen closed 1 year ago

HolgerGottChristensen commented 1 year ago

Hello

First off, thank you for the very useful service. I have started getting errors when trying to reach endpoints from the site.

I am trying to get an image from the url: https://picsum.photos/300

When I go the the URL in a browser(safari) it shows up fine, but when trying to request it via the Rust library https://github.com/seanmonstar/reqwest, it returns 403 access forbidden.

From my research of "error code 1020" it seems to be a firewall or configuration issue on the hosting side, and not something on the library site. I was wondering if this is intended as it used to work.

Below I have included the full response I get from the request. It includes a "report-to" endpoint, so maybe you have access to that and can see what went wrong.

If you miss any information, or something is not clear, I will try my best to update the issue.

Thank You :D

Response {
    url: Url {
        scheme: "https",
        cannot_be_a_base: false,
        username: "",
        password: None,
        host: Some(
            Domain(
                "picsum.photos",
            ),
        ),
        port: None,
        path: "/id/200/300/300.jpg",
        query: None,
        fragment: None,
    },
    status: 403,
    headers: {
        "date": "Sun, 01 Jan 2023 10:33:55 GMT",
        "content-type": "text/plain; charset=UTF-8",
        "content-length": "16",
        "connection": "keep-alive",
        "x-frame-options": "SAMEORIGIN",
        "referrer-policy": "same-origin",
        "cache-control": "private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0",
        "expires": "Thu, 01 Jan 1970 00:00:01 GMT",
        "report-to": "{\"endpoints\":[{\"url\":\"https:\/\/a.nel.cloudflare.com\/report\/v3?s=g6NMvy0TqfAlb2REWEMBYRJb5U3%2B1TqsE4nbv2Cq67DsamanJ6dfPTT3w5pP3vHgTCG6N1SUW6DeNsESDdJhjaVTr%2BJBRbPHAYXFdgv8wv8x744mVMumkqhzs5NOe2I%3D\"}],\"group\":\"cf-nel\",\"max_age\":604800}",
        "nel": "{\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}",
        "strict-transport-security": "max-age=15552000",
        "x-content-type-options": "nosniff",
        "server": "cloudflare",
        "cf-ray": "782a997afa3dbe53-CPH",
        "alt-svc": "h3=\":443\"; ma=86400, h3-29=\":443\"; ma=86400",
    },
}
DMarby commented 1 year ago

Hi @HolgerGottChristensen,

Apologies for the trouble. It looks like your request got blocked as it was missing a user agent. Please ensure that you are setting the User-Agent header in whatever library you are using, and it should start working. Hope this helps, let me know if you run into any further issues.

HolgerGottChristensen commented 1 year ago

Thank you for the help.

It works now after setting the header. I didn't know it had become a requirement.

Thank you for the quick response :D