Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 0 additions & 39 deletions app/api/upload/route.ts

This file was deleted.

9 changes: 5 additions & 4 deletions hooks/usePureFileAttachments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useVercelChatContext } from "@/providers/VercelChatProvider";
import { CHAT_INPUT_SUPPORTED_FILE } from "@/lib/chat/config";
import { isAllowedByExtension } from "@/lib/files/isAllowedByExtension";
import { getFileExtension } from "@/lib/files/getFileExtension";
import { getClientApiBaseUrl } from "@/lib/api/getClientApiBaseUrl";

export function usePureFileAttachments() {
const { setAttachments, addTextAttachment } = useVercelChatContext();
Expand Down Expand Up @@ -57,7 +58,7 @@ export function usePureFileAttachments() {
const formData = new FormData();
formData.append("file", file);

const response = await fetch("/api/upload", {
const response = await fetch(`${getClientApiBaseUrl()}/api/upload`, {
method: "POST",
body: formData,
});
Expand All @@ -83,8 +84,8 @@ export function usePureFileAttachments() {
mediaType: data.fileType,
url: data.url,
} as FileUIPart)
: attachment
)
: attachment,
),
);

// Revoke the temporary object URL to avoid memory leaks
Expand All @@ -93,7 +94,7 @@ export function usePureFileAttachments() {
console.error("Error uploading file:", error);
// Remove the failed attachment
setAttachments((prev: FileUIPart[]) =>
prev.filter((a: FileUIPart) => a.url !== tempUrl)
prev.filter((a: FileUIPart) => a.url !== tempUrl),
);
// Revoke the temporary object URL
URL.revokeObjectURL(tempUrl);
Expand Down
4 changes: 3 additions & 1 deletion lib/arweave/uploadFile.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { getClientApiBaseUrl } from "@/lib/api/getClientApiBaseUrl";

export type ArweaveUploadResponse = {
id: string;
uri: string;
Expand All @@ -10,7 +12,7 @@ export const uploadFile = async (
const data = new FormData();
data.set("file", file);

const res = await fetch("/api/upload", {
const res = await fetch(`${getClientApiBaseUrl()}/api/upload`, {
method: "POST",
body: data,
});
Expand Down
6 changes: 6 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ const nextConfig = {
port: '',
pathname: '/**',
},
{
protocol: 'https',
hostname: '*.supabase.co',
port: '',
pathname: '/storage/v1/object/public/**',
},
],
},
};
Expand Down
Loading