Revert "Block redirects explicitly in fetch-url API route"
Browse files
src/routes/api/fetch-url/+server.ts
CHANGED
|
@@ -48,17 +48,12 @@ export async function GET({ url, fetch }) {
|
|
| 48 |
|
| 49 |
const response = await fetch(targetUrl, {
|
| 50 |
signal: controller.signal,
|
| 51 |
-
redirect: "
|
| 52 |
headers: {
|
| 53 |
"User-Agent": "HuggingChat-Attachment-Fetcher/1.0",
|
| 54 |
},
|
| 55 |
}).finally(() => clearTimeout(timeoutId));
|
| 56 |
|
| 57 |
-
// Explicitly block redirects
|
| 58 |
-
if (response.status >= 300 && response.status < 400) {
|
| 59 |
-
throw error(400, "Redirects are not allowed");
|
| 60 |
-
}
|
| 61 |
-
|
| 62 |
if (!response.ok) {
|
| 63 |
throw error(response.status, `Failed to fetch: ${response.statusText}`);
|
| 64 |
}
|
|
|
|
| 48 |
|
| 49 |
const response = await fetch(targetUrl, {
|
| 50 |
signal: controller.signal,
|
| 51 |
+
redirect: "error", // Block all redirects
|
| 52 |
headers: {
|
| 53 |
"User-Agent": "HuggingChat-Attachment-Fetcher/1.0",
|
| 54 |
},
|
| 55 |
}).finally(() => clearTimeout(timeoutId));
|
| 56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
if (!response.ok) {
|
| 58 |
throw error(response.status, `Failed to fetch: ${response.statusText}`);
|
| 59 |
}
|