Skip to content
Merged
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
6 changes: 5 additions & 1 deletion api/avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function isAllowedAvatarUrl(rawUrl) {
return ALLOWED_AVATAR_HOSTS.has(url.hostname.toLowerCase());
}

export default async function handler(req) {
export async function handler(req) {
if (req.method === 'OPTIONS') {
return new Response(null, { status: 204, headers: corsHeaders });
}
Expand Down Expand Up @@ -76,3 +76,7 @@ export default async function handler(req) {
return new Response('Avatar proxy error', { status: 502, headers: corsHeaders });
}
}

// Vercel's Node.js runtime ignores a Response returned from a default-exported
// function, so expose the Web `fetch` handler it recognizes instead.
export default { fetch: handler };
6 changes: 5 additions & 1 deletion api/deleteAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const corsHeaders = {
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
};

export default async function handler(req) {
export async function handler(req) {
if (req.method === 'OPTIONS') {
return new Response(null, { status: 204, headers: corsHeaders });
}
Expand Down Expand Up @@ -95,3 +95,7 @@ export default async function handler(req) {
});
}
}

// Vercel's Node.js runtime ignores a Response returned from a default-exported
// function, so expose the Web `fetch` handler it recognizes instead.
export default { fetch: handler };
6 changes: 5 additions & 1 deletion api/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const corsHeaders = {
'Access-Control-Allow-Headers': 'Content-Type',
};

export default async function handler(req) {
export async function handler(req) {
if (req.method === 'OPTIONS') {
return new Response(null, { status: 204, headers: corsHeaders });
}
Expand Down Expand Up @@ -236,3 +236,7 @@ export default async function handler(req) {
});
}
}

// Vercel's Node.js runtime ignores a Response returned from a default-exported
// function, so expose the Web `fetch` handler it recognizes instead.
export default { fetch: handler };
8 changes: 6 additions & 2 deletions api/downloadThumbnail.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function isAllowedThumbnailUrl(rawUrl) {
return ALLOWED_THUMBNAIL_HOSTS.has(u.hostname.toLowerCase());
}

export default async function handler(req) {
export async function handler(req) {
if (req.method === 'OPTIONS') {
return new Response(null, { status: 204, headers: corsHeaders });
}
Expand Down Expand Up @@ -89,4 +89,8 @@ export default async function handler(req) {
headers: { ...corsHeaders, 'Content-Type': 'application/json' },
});
}
}
}

// Vercel's Node.js runtime ignores a Response returned from a default-exported
// function, so expose the Web `fetch` handler it recognizes instead.
export default { fetch: handler };
8 changes: 6 additions & 2 deletions api/generateTitles.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function generateTitlesWithOpenRouter(description, creativity) {
return data.choices[0].message.content;
}

export default async function handler(req) {
export async function handler(req) {
// Handle OPTIONS preflight request
if (req.method === 'OPTIONS') {
return new Response(null, {
Expand Down Expand Up @@ -132,4 +132,8 @@ export default async function handler(req) {
headers: { ...corsHeaders, 'Content-Type': 'application/json' }
});
}
}
}

// Vercel's Node.js runtime ignores a Response returned from a default-exported
// function, so expose the Web `fetch` handler it recognizes instead.
export default { fetch: handler };
6 changes: 5 additions & 1 deletion api/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ function setCachedInfo(url, data) {
}
}

export default async function handler(req) {
export async function handler(req) {
if (req.method === 'OPTIONS') {
return new Response(null, { status: 204, headers: corsHeaders });
}
Expand Down Expand Up @@ -353,3 +353,7 @@ This is a common issue affecting all YouTube downloaders and is not specific to
});
}
}

// Vercel's Node.js runtime ignores a Response returned from a default-exported
// function, so expose the Web `fetch` handler it recognizes instead.
export default { fetch: handler };
6 changes: 5 additions & 1 deletion api/looney-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export const config = {

class ValidationError extends Error {}

export default async function handler(request) {
export async function handler(request) {
if (request.method === 'OPTIONS') {
return new Response(null, { status: 204, headers: corsHeaders(request) });
}
Expand Down Expand Up @@ -318,3 +318,7 @@ export default async function handler(request) {
return jsonResponse(request, { error: message }, status);
}
}

// Vercel's Node.js runtime ignores a Response returned from a default-exported
// function, so expose the Web `fetch` handler it recognizes instead.
export default { fetch: handler };
4 changes: 3 additions & 1 deletion api/uptime.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,6 @@ export async function handler(request) {
}
}

export default handler;
// Vercel's Node.js runtime ignores a Response returned from a default-exported
// function, so expose the Web `fetch` handler it recognizes instead.
export default { fetch: handler };
14 changes: 7 additions & 7 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import dotenv from 'dotenv';
import express from 'express';
import cors from 'cors';
import { Readable } from 'stream';
import infoHandler from './api/info.js';
import downloadHandler from './api/download.js';
import downloadThumbnailHandler from './api/downloadThumbnail.js';
import generateTitlesHandler from './api/generateTitles.js';
import deleteAccountHandler from './api/deleteAccount.js';
import avatarHandler from './api/avatar.js';
import looneyCheckHandler from './api/looney-check.js';
import { handler as infoHandler } from './api/info.js';
import { handler as downloadHandler } from './api/download.js';
import { handler as downloadThumbnailHandler } from './api/downloadThumbnail.js';
import { handler as generateTitlesHandler } from './api/generateTitles.js';
import { handler as deleteAccountHandler } from './api/deleteAccount.js';
import { handler as avatarHandler } from './api/avatar.js';
import { handler as looneyCheckHandler } from './api/looney-check.js';
import { handler as musicLinkHandler } from './api/music-link.js';
import { handler as trackHandler } from './api/track.js';
import { handler as statsHandler } from './api/stats.js';
Expand Down
Loading