fix: share-links missen het /ipfs/-segment

- gatewayLink() bouwde <gateway>/<cid>; dat pad bestaat niet in deze app
- Nu <gateway>/ipfs/<cid>, wat overeenkomt met de route GET /ipfs/<cid>
- Gateway-basis komt uit gatewayUrl() in lib/config.ts (NEXT_PUBLIC_GATEWAY_URL)
- Optionele filename -> ?filename=, uitgeconsumed door dezelfde route
- downloadViaGateway() hergebruikt de helper i.p.v. eigen gateway-constant
  (valideerde fallback-host was de oude maos.dedyn.io)
- helpers.test.ts legde het foute pad vast; asserties vervangen door de
  werkelijke vorm + een test op de config-override
This commit is contained in:
maikrolf
2026-10-01 19:13:43 +02:00
parent 88f2c7e5aa
commit 4a5b146713
3 changed files with 65 additions and 11 deletions
+3 -2
View File
@@ -2,6 +2,8 @@
* Utility om IPFS content te downloaden als bestand.
*/
import { gatewayLink } from './helpers';
/**
* Download een bestand van IPFS via de explorer/cat proxy.
* Maakt een Blob van de response en simuleert een klik op <a download>.
@@ -34,9 +36,8 @@ export async function downloadFile(cid: string, filename?: string): Promise<void
* Download via gateway (alternatief als proxy traag is).
*/
export function downloadViaGateway(cid: string, filename?: string) {
const gateway = process.env.NEXT_PUBLIC_GATEWAY_URL || 'https://maos.dedyn.io';
const a = document.createElement('a');
a.href = `${gateway}/ipfs/${cid}`;
a.href = gatewayLink(cid);
a.download = filename || cid;
a.target = '_blank';
a.rel = 'noopener noreferrer';