1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Send Content-Type header on response for asset request

Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
Lauri Nevala 2020-03-31 23:21:55 +03:00
parent f0dd4095ac
commit 620f19fb3b

View File

@ -18,6 +18,19 @@ declare const __static: string;
const assetsPath = path.join(__static, "build/client") const assetsPath = path.join(__static, "build/client")
const mimeTypes: { [key:string]:string; } = {
"html": "text/html",
"txt": "text/plain",
"css": "text/css",
"gif": "image/gif",
"jpg": "image/jpeg",
"png": "image/png",
"svg": "image/svg+xml",
"js": "application/javascript",
"woff2": "font/woff2",
"ttf": "font/ttf"
};
interface RouteParams { interface RouteParams {
[key: string]: string | undefined; [key: string]: string | undefined;
} }
@ -80,6 +93,8 @@ export class Router {
if (err) { if (err) {
response.statusCode = 404 response.statusCode = 404
} else { } else {
const type = mimeTypes[path.extname(asset).slice(1)] || "text/plain";
response.setHeader("Content-Type", type);
response.write(data) response.write(data)
response.end() response.end()
} }