Fix download endpoint
This commit is contained in:
parent
b26f724be8
commit
941c35c1ef
|
@ -25,7 +25,7 @@ import {
|
||||||
import { MVideoSource } from '@server/types/models/video/video-source.js'
|
import { MVideoSource } from '@server/types/models/video/video-source.js'
|
||||||
import cors from 'cors'
|
import cors from 'cors'
|
||||||
import express from 'express'
|
import express from 'express'
|
||||||
import { DOWNLOAD_PATHS } from '../initializers/constants.js'
|
import { DOWNLOAD_PATHS, WEBSERVER } from '../initializers/constants.js'
|
||||||
import {
|
import {
|
||||||
asyncMiddleware, buildRateLimiter, optionalAuthenticate,
|
asyncMiddleware, buildRateLimiter, optionalAuthenticate,
|
||||||
originalVideoFileDownloadValidator,
|
originalVideoFileDownloadValidator,
|
||||||
|
@ -252,7 +252,7 @@ async function downloadGeneratedVideoFile (req: express.Request, res: express.Re
|
||||||
: maxResolutionFile.extname
|
: maxResolutionFile.extname
|
||||||
|
|
||||||
// If there is the extension, we want to simulate a "raw file" and so not send the content disposition header
|
// 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')) {
|
if (!urlPath.endsWith('.mp4') && !urlPath.endsWith('.m4a')) {
|
||||||
const downloadFilename = buildDownloadFilename({ video, extname })
|
const downloadFilename = buildDownloadFilename({ video, extname })
|
||||||
res.setHeader('Content-disposition', `attachment; filename="${encodeURI(downloadFilename)}`)
|
res.setHeader('Content-disposition', `attachment; filename="${encodeURI(downloadFilename)}`)
|
||||||
|
|
Loading…
Reference in New Issue