Skip to content

Commit

Permalink
Proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed Dec 13, 2023
1 parent 62c48ab commit 414254a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
7 changes: 4 additions & 3 deletions apps/dashboard/src/app/api/proxy/route.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
export const runtime = "edge";
export const dynamic = "force-dynamic";

export async function GET(req) {
const requestUrl = new URL(req.url);
const filePath = requestUrl.searchParams.get("filePath");

return fetch(
`${process.env.NEXT_PUBLIC_SUPABASE_URL}/storage/v1/object/${filePath}`,
`${process.env.NEXT_PUBLIC_SUPABASE_URL}/storage/v1/object/${filePath}?wefwef`,
{
cache: "no-cache",
headers: {
authorization: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
authorization: `Bearer ${process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!}`,
},
}
);
Expand Down
24 changes: 14 additions & 10 deletions apps/dashboard/src/components/attachments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,27 @@ const Item = ({ file, onDelete, id }) => {
<HoverCard openDelay={300}>
<HoverCardTrigger>
<div className="rounded-md border w-[40px] h-[40px] flex items-center justify-center overflow-hidden cursor-pointer">
<embed
src={`/api/proxy?filePath=vault/${file.path}#toolbar=0`}
title={file.name}
className="w-[40px] h-[40px] pointer-none"
/>
{file.path && (
<embed
src={`/api/proxy?filePath=vault/${file.path}#toolbar=0`}
title={file.name}
className="w-[40px] h-[40px] pointer-none"
/>
)}
</div>
</HoverCardTrigger>
<HoverCardContent
className="w-70 h-[350px]"
side="left"
sideOffset={55}
>
<embed
src={`/api/proxy?filePath=vault/${file.path}#toolbar=0`}
title={file.name}
className="w-80 h-full"
/>
{file.path && (
<embed
src={`/api/proxy?filePath=vault/${file.path}#toolbar=0`}
title={file.name}
className="w-80 h-full"
/>
)}
</HoverCardContent>
</HoverCard>

Expand Down

0 comments on commit 414254a

Please sign in to comment.