ELECTRON: Specify mime type when loading wasm files (#2262)

This commit is contained in:
catloversg
2025-07-23 03:24:00 +07:00
committed by GitHub
parent 902367d8b6
commit 1ac95144be

View File

@@ -219,7 +219,11 @@ app.on("ready", async () => {
relativePath = path.relative(__dirname, realPath);
// Only allow access to files in "dist" folder or html files in the same directory
if (method === "GET" && (relativePath.startsWith("dist") || relativePath.match(/^[a-zA-Z-_]*\.html/))) {
return new Response(readFileSync(realPath));
const customHeaders = {};
if (relativePath.endsWith(".wasm")) {
customHeaders["Content-Type"] = "application/wasm";
}
return new Response(readFileSync(realPath), { headers: new Headers(customHeaders) });
}
} catch (error) {
log.error(error);