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 2cf8364 commit 2aeb940
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
20 changes: 20 additions & 0 deletions apps/dashboard/src/app/api/proxy/route.ts
Original file line number Diff line number Diff line change
@@ -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!,
},
}
);
}
8 changes: 3 additions & 5 deletions apps/dashboard/src/components/attachments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -24,10 +24,8 @@ 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">
{/* <File size={18} /> */}

<embed
src={`https://service.midday.ai/storage/v1/object/public/vault/${file.path}#toolbar=0`}
src={`/api/proxy?filePath=vault/${file.path}#toolbar=0`}
title={file.name}
className="w-[40px] h-[40px] pointer-none"
/>
Expand All @@ -39,7 +37,7 @@ const Item = ({ file, onDelete, id }) => {
sideOffset={55}
>
<embed
src={`https://service.midday.ai/storage/v1/object/public/vault/${file.path}#toolbar=0`}
src={`/api/proxy?filePath=vault/${file.path}#toolbar=0`}
title={file.name}
className="w-80 h-full"
/>
Expand Down

0 comments on commit 2aeb940

Please sign in to comment.