File tree Expand file tree Collapse file tree
tools/pinterest-downloader Expand file tree Collapse file tree Load diff This file was deleted.
Original file line number Diff line number Diff 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 - z 0 - 9 ] / gi, '_' ) . toLowerCase ( ) } _${ index } .jpg` ;
101104 folder ?. file ( fileName , blob ) ;
You can’t perform that action at this time.
0 commit comments