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 (#190)

Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
Lauri Nevala 2020-04-01 07:20:40 +03:00 committed by GitHub
parent 5c2e64b487
commit eab8231f92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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()
} }