From 9d3443ceac58703183eda1d76077e1148c8956fd Mon Sep 17 00:00:00 2001 From: diced Date: Wed, 23 Jun 2021 21:34:38 -0700 Subject: [PATCH] fix(server): add mimetype for non db entries --- server/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/index.js b/server/index.js index 5be2ac4..97af6e8 100644 --- a/server/index.js +++ b/server/index.js @@ -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);