Skip to content

Commit fe5a8e3

Browse files
authored
fix: disable download no-cors (#2200)
1 parent 6da4350 commit fe5a8e3

File tree

1 file changed

+4
-2
lines changed
  • packages/fern-docs/ui/src/mdx/components/download

1 file changed

+4
-2
lines changed

packages/fern-docs/ui/src/mdx/components/download/Download.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { last } from "es-toolkit/array";
12
import React, { ComponentProps, PropsWithChildren } from "react";
23
import { FernLink } from "../../../components/FernLink";
34
import { Button } from "../button";
@@ -24,12 +25,13 @@ export function Download({
2425

2526
e.preventDefault();
2627
try {
27-
const response = await fetch(src, { mode: "no-cors" });
28+
const response = await fetch(src);
2829
const blob = await response.blob();
2930
const blobUrl = URL.createObjectURL(blob);
3031
const a = document.createElement("a");
3132
a.href = blobUrl;
32-
a.download = filename || "";
33+
// if the filename is not provided, use the last part of the src
34+
a.download = filename || last(src.split("/")) || "";
3335
document.body.appendChild(a);
3436
a.click();
3537
document.body.removeChild(a);

0 commit comments

Comments
 (0)