From 2aeb94028c796d203bca6536a5a60c7daa6aa281 Mon Sep 17 00:00:00 2001 From: Pontus Abrahamsson Date: Wed, 13 Dec 2023 19:20:10 +0100 Subject: [PATCH] Proxy --- apps/dashboard/src/app/api/proxy/route.ts | 20 +++++++++++++++++++ apps/dashboard/src/components/attachments.tsx | 8 +++----- 2 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 apps/dashboard/src/app/api/proxy/route.ts diff --git a/apps/dashboard/src/app/api/proxy/route.ts b/apps/dashboard/src/app/api/proxy/route.ts new file mode 100644 index 0000000000..f08c9f2558 --- /dev/null +++ b/apps/dashboard/src/app/api/proxy/route.ts @@ -0,0 +1,20 @@ +export const runtime = "edge"; + +export async function GET(req) { + const requestUrl = new URL(req.url); + const filePath = requestUrl.searchParams.get("filePath"); + + console.log( + `${process.env.NEXT_PUBLIC_SUPABASE_URL}/storage/v1/object/${filePath}` + ); + + return fetch( + `${process.env.NEXT_PUBLIC_SUPABASE_URL}/storage/v1/object/${filePath}`, + { + headers: { + // TODO: Use current user token instead + authorization: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!, + }, + } + ); +} diff --git a/apps/dashboard/src/components/attachments.tsx b/apps/dashboard/src/components/attachments.tsx index c765b5f527..6e9eda9e60 100644 --- a/apps/dashboard/src/components/attachments.tsx +++ b/apps/dashboard/src/components/attachments.tsx @@ -13,7 +13,7 @@ import { HoverCardTrigger, } from "@midday/ui/hover-card"; import { cn } from "@midday/ui/utils"; -import { File, X } from "lucide-react"; +import { X } from "lucide-react"; import { useEffect, useState } from "react"; import { useDropzone } from "react-dropzone"; @@ -24,10 +24,8 @@ const Item = ({ file, onDelete, id }) => {
- {/* */} - @@ -39,7 +37,7 @@ const Item = ({ file, onDelete, id }) => { sideOffset={55} >