fix(server): add mimetype for non db entries

This commit is contained in:
diced 2021-06-23 21:34:38 -07:00
parent d628424b35
commit 9d3443ceac
No known key found for this signature in database
GPG key ID: 85AB64C74535D76E

View file

@ -3,13 +3,15 @@ const { createServer } = require('http');
const { readFile, stat, mkdir } = require('fs/promises');
const { existsSync } = require('fs');
const { execSync } = require('child_process');
const { join } = require('path');
const { join, extname } = require('path');
const { red, green, bold } = require('colorette');
const { PrismaClient } = require('@prisma/client');
const validateConfig = require('./validateConfig');
const Logger = require('../src/lib/logger');
const getFile = require('./static');
const readConfig = require('../src/lib/readConfig');
const mimes = require('../scripts/mimes');
Logger.get('server').info('starting zipline server');
@ -89,6 +91,9 @@ function shouldUseYarn() {
}
});
res.setHeader('Content-Type', image.mimetype);
} else {
const mimetype = mimes[extname(parts[2])] ?? 'application/octet-stream';
res.setHeader('Content-Type', mimetype);
}
res.end(data);