tapio / live-server

A simple development http server with live reload capability.
http://tapiov.net/live-server/
4.43k stars 484 forks source link

.wasm file is sent as application/octet-stream from the server #284

Open LoganDark opened 5 years ago

LoganDark commented 5 years ago

Emscripten fails to load its WebAssembly due to an invalid MIME type.

wasm streaming compile failed: TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'.

live-server returns application/octet-stream but should return application/wasm.

Software details

Filyus commented 5 years ago

72: var fileExt = ""; 82: fileExt = path.extname(filepath).toLocaleLowerCase(); 83: var match, possibleExtensions = ["", ".html", ".htm", ".xhtml", ".php", ".svg"]; 84: if (hasNoOrigin && (possibleExtensions.indexOf(fileExt) > -1)) { 112: if (fileExt == ".wasm") { 113: res.setHeader('Content-Type', 'application/wasm'); 114: }

LoganDark commented 5 years ago

@Filyus Huh?

Filyus commented 5 years ago

Just fixed for myself, maybe someone will come in handy.

LoganDark commented 5 years ago

@Filyus Pull request?

Filyus commented 5 years ago

Probably.

LoganDark commented 5 years ago

@Filyus Probably? You're not going to make one?

Filyus commented 5 years ago

I have no time. I will be grateful if you do it for me.

LoganDark commented 5 years ago

@Filyus You have the time to edit the code, but not to make a pull request?

Look, I have no idea what this means:

72: var fileExt = "";
82: fileExt = path.extname(filepath).toLocaleLowerCase();
83: var match, possibleExtensions = ["", ".html", ".htm", ".xhtml", ".php", ".svg"];
84: if (hasNoOrigin && (possibleExtensions.indexOf(fileExt) > -1)) {
112: if (fileExt == ".wasm") {
113: res.setHeader('Content-Type', 'application/wasm');
114: }
Filyus commented 5 years ago

I finally did it.

LoganDark commented 5 years ago

@Filyus Thanks! I hope a maintainer won't mind adjusting the indentation though :p

1j01 commented 3 years ago

Workaround: you can upgrade send in your project, and live-server should use it. npm i send@0.17.1 --save-dev (latest version as of writing) or npm i send@latest --save-dev Make sure to restart the live-server and do a hard refresh of your app to avoid a cached wrong-mime-type response.