Skip to content

Commit 8940484

Browse files
fix: switch to Cloudflare Worker backend for static site compatibility
1 parent 15b5577 commit 8940484

2 files changed

Lines changed: 5 additions & 71 deletions

File tree

app/api/pinterest/fetch/route.ts

Lines changed: 0 additions & 69 deletions
This file was deleted.

app/tools/pinterest-downloader/page.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ export default function PinterestDownloader() {
2828
setPins([]);
2929

3030
try {
31-
const res = await fetch(`/api/pinterest/fetch?url=${encodeURIComponent(url)}`);
31+
const workerUrl = `https://cloudflare-workers-autoconfig-pinflow.safi4730358.workers.dev/api/fetch.php?url=${encodeURIComponent(url)}`;
32+
const res = await fetch(workerUrl);
3233
const data = await res.json();
3334

3435
if (data.error) {
@@ -95,7 +96,9 @@ export default function PinterestDownloader() {
9596

9697
const downloadPromises = pins.map(async (pin, index) => {
9798
try {
98-
const response = await fetch(pin.url);
99+
// Use the worker proxy for raw image download to bypass CORS
100+
const proxyImageUrl = `https://cloudflare-workers-autoconfig-pinflow.safi4730358.workers.dev/api/fetch.php?url=${encodeURIComponent(pin.url)}&raw=true`;
101+
const response = await fetch(proxyImageUrl);
99102
const blob = await response.blob();
100103
const fileName = `${pin.title.replace(/[^a-z0-9]/gi, '_').toLowerCase()}_${index}.jpg`;
101104
folder?.file(fileName, blob);

0 commit comments

Comments
 (0)