If you prefer not to rely on third-party image proxy servers, you can set up your own! By hosting your own proxy server, you can access images from Pixiv by simply changing the Referer to https://www.pixiv.net/.
By hosting your own Pixiv image proxy server, you can have more control over the caching and access to Pixiv images without relying on external services.
addEventListener("fetch",event=>{event.respondWith(handleRequest(event.request));});asyncfunctionhandleRequest(originalRequest){try{leturl=newURL(originalRequest.url);url.hostname="i.pximg.net";letmodifiedRequest=newRequest(url,originalRequest);letresponse=awaitfetch(modifiedRequest,{headers:{'Referer':'https://www.pixiv.net/','User-Agent':'Mozilla/5.0 (Windows NT 10.0; rv:122.0) Gecko/20100101 Firefox/122.0'}});if(!response.ok){returnnewResponse("Error fetching the resource.",{status:response.status});}returnresponse;}catch(error){console.error("Failed to fetch resource: ",error.message);returnnewResponse("An error occurred while fetching the resource.",{status:500});}}
For more information, you can refer to this article by pixiv.cat, which also serves as an image proxy server. You can try an example image through their proxy.