Skip to content

Commit

Permalink
chore: remove useless headers
Browse files Browse the repository at this point in the history
  • Loading branch information
Vexcited committed Aug 12, 2023
1 parent 2c5e980 commit 73c4171
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/routes/api/file/[upload_id].ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { type APIEvent, json } from "solid-start";
import { contentType as mime_type } from "mime-types";
// import { contentType as mime_type } from "mime-types";

import { supabase, getUserProfile } from "@/supabase/server";
import { UploadedFile, UserProfile } from "@/types/api";

export const GET = async ({ request, params }: APIEvent): Promise<Response> => {
try {
const { upload_id } = params;
let { upload_id } = params;
let token = request.headers.get("authorization");

// if (upload_id.includes(".")) {
// upload_id = upload_id.substring(0, upload_id.indexOf("."));
// }
const { data: file_data } = await supabase
.from("uploads")
.select()
Expand Down Expand Up @@ -57,7 +60,7 @@ export const GET = async ({ request, params }: APIEvent): Promise<Response> => {
}

const file_extension = file_data.name.substring(file_data.name.lastIndexOf(".") + 1);
const file_content_type = mime_type(file_extension);
// const file_content_type = mime_type(file_extension);

// Create a download URL, only available for 15s.
const { data } = await supabase.storage
Expand All @@ -67,13 +70,11 @@ export const GET = async ({ request, params }: APIEvent): Promise<Response> => {
const headers = new Headers();
headers.set("access-control-allow-origin", "*");
headers.set("location", data!.signedUrl);
headers.set("Cache-Control", "300");
headers.set("Content-Disposition", `attachment; filename="${file_data.name}"`);
headers.set("Link", `<https://drive.cattolabs.com/api/file/${file_data.id}>; rel="canonical"`)
// headers.set("Cache-Control", "300");

if (file_content_type) {
headers.set("content-type", file_content_type);
}
// if (file_content_type) {
// headers.set("content-type", file_content_type);
// }

const response = new Response(null, {
status: 301,
Expand Down

0 comments on commit 73c4171

Please sign in to comment.