Fix download endpoint

This commit is contained in:
Chocobozzz 2025-02-20 06:12:31 +01:00
parent b26f724be8
commit 941c35c1ef
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 2 additions and 2 deletions

View File

@ -25,7 +25,7 @@ import {
import { MVideoSource } from '@server/types/models/video/video-source.js'
import cors from 'cors'
import express from 'express'
import { DOWNLOAD_PATHS } from '../initializers/constants.js'
import { DOWNLOAD_PATHS, WEBSERVER } from '../initializers/constants.js'
import {
asyncMiddleware, buildRateLimiter, optionalAuthenticate,
originalVideoFileDownloadValidator,
@ -252,7 +252,7 @@ async function downloadGeneratedVideoFile (req: express.Request, res: express.Re
: maxResolutionFile.extname
// If there is the extension, we want to simulate a "raw file" and so not send the content disposition header
const urlPath = new URL(req.originalUrl).pathname
const urlPath = new URL(req.originalUrl, WEBSERVER.URL).pathname
if (!urlPath.endsWith('.mp4') && !urlPath.endsWith('.m4a')) {
const downloadFilename = buildDownloadFilename({ video, extname })
res.setHeader('Content-disposition', `attachment; filename="${encodeURI(downloadFilename)}`)