From 911ca86a0d1025d41870fd1e9cb39ca038df28cb Mon Sep 17 00:00:00 2001 From: MasutaYunikon Date: Sat, 23 May 2026 03:37:30 +0200 Subject: [PATCH] fix: cors, alldebrid --- package.json | 1 + pnpm-lock.yaml | 18 ++++++++++++++++++ server/index.ts | 8 ++++++++ server/torrent-clients/alldebrid.ts | 3 +++ src/views/settings/DownloadClientView.vue | 2 +- 5 files changed, 31 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 58103f5..96b4388 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "@vueuse/core": "^14.2.1", "bcryptjs": "^3.0.3", "cookie-parser": "^1.4.7", + "cors": "^2.8.6", "express": "^5.2.1", "jsonwebtoken": "^9.0.3", "lucide-vue-next": "^1.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 61c5dd4..71c9ec6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,6 +20,9 @@ importers: cookie-parser: specifier: ^1.4.7 version: 1.4.7 + cors: + specifier: ^2.8.6 + version: 2.8.6 express: specifier: ^5.2.1 version: 5.2.1 @@ -758,6 +761,10 @@ packages: resolution: {integrity: sha512-7Vv6asjS4gMOuILabD3l739tsaxFQmC+a7pLZm02zyvs8p977bL3zEgq3yDk5rn9B0PbYgIv++jmHcuUab4RhA==} engines: {node: '>=18'} + cors@2.8.6: + resolution: {integrity: sha512-tJtZBBHA6vjIAaF6EnIaq6laBBP9aq/Y3ouVJjEfoHbRBcHBAHYcMh/w8LDrk2PvIMMq8gmopa5D4V8RmbrxGw==} + engines: {node: '>= 0.10'} + csstype@3.2.3: resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==} @@ -1126,6 +1133,10 @@ packages: resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + object-assign@4.1.1: + resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==} + engines: {node: '>=0.10.0'} + object-inspect@1.13.4: resolution: {integrity: sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==} engines: {node: '>= 0.4'} @@ -2045,6 +2056,11 @@ snapshots: dependencies: is-what: 5.5.0 + cors@2.8.6: + dependencies: + object-assign: 4.1.1 + vary: 1.1.2 + csstype@3.2.3: {} data-uri-to-buffer@4.0.1: {} @@ -2401,6 +2417,8 @@ snapshots: fetch-blob: 3.2.0 formdata-polyfill: 4.0.10 + object-assign@4.1.1: {} + object-inspect@1.13.4: {} on-finished@2.4.1: diff --git a/server/index.ts b/server/index.ts index a352af7..e116cdb 100644 --- a/server/index.ts +++ b/server/index.ts @@ -21,6 +21,7 @@ import { readAvailable, readInfohashMap, loadEnrichedSeriesData } from './lib/gi import { pushNotif } from './lib/notifs.js' import { readRequests, completeRequest } from './requests.js' import { checkNfoUpdates } from './lib/nfo.js' +import cors from 'cors'; import usersRouter from './routes/users.js' import invitesRouter from './routes/invites.js' @@ -53,6 +54,13 @@ const PORT = Number(process.env.PORT) || 9898 app.use(express.json()) app.use(cookieParser()) + +app.use(cors({ + origin: '*', + methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'], + allowedHeaders: ['Content-Type', 'Authorization'], +})); + const PUBLIC_PATH = path.join(BASE_DIR, 'public') if (fs.existsSync(PUBLIC_PATH)) { app.use(express.static(PUBLIC_PATH)) diff --git a/server/torrent-clients/alldebrid.ts b/server/torrent-clients/alldebrid.ts index f4e572a..7731220 100644 --- a/server/torrent-clients/alldebrid.ts +++ b/server/torrent-clients/alldebrid.ts @@ -97,6 +97,9 @@ const adDriver: TorrentClientDriver = { }, async add(config, url, options?: DownloadOptions) { + if (options?.file_index != null) + logger.warn('alldebrid', `Sélection de fichier (index ${options.file_index}) non supportée par AllDebrid — pack complet téléchargé`) + const isMagnet = url.startsWith('magnet:') const hash = (options?.infohash?.toLowerCase() ?? null) || url.match(/xt=urn:btih:([a-fA-F0-9]{40,})/i)?.[1]?.toLowerCase() diff --git a/src/views/settings/DownloadClientView.vue b/src/views/settings/DownloadClientView.vue index eae2cff..596ec2b 100644 --- a/src/views/settings/DownloadClientView.vue +++ b/src/views/settings/DownloadClientView.vue @@ -257,7 +257,7 @@ const clientMatrix = [ }, { id: 'alldebrid', label: 'AllDebrid', version: 'API v4', - auth: 'Clé API', fileSelect: true, fileProgress: true, torrentUpload: 'proxy', categories: false, deleteFiles: true, + auth: 'Clé API', fileSelect: false, fileProgress: true, torrentUpload: 'proxy', categories: false, deleteFiles: true, }, ]