live-server icon indicating copy to clipboard operation
live-server copied to clipboard

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

Open LoganDark opened this issue 7 years ago • 11 comments

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

  • Command line used for launching live-server: live-server
  • OS: macOS 10.14.1 Mojave (build 18B50c)
  • Node.js version: v10.1.0
  • live-server version: 1.2.0

LoganDark avatar Nov 24 '18 09:11 LoganDark

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 avatar May 28 '19 10:05 Filyus

@Filyus Huh?

LoganDark avatar May 28 '19 10:05 LoganDark

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

Filyus avatar May 28 '19 10:05 Filyus

@Filyus Pull request?

LoganDark avatar May 28 '19 10:05 LoganDark

Probably.

Filyus avatar May 28 '19 10:05 Filyus

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

LoganDark avatar May 28 '19 10:05 LoganDark

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

Filyus avatar May 29 '19 03:05 Filyus

@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: }

LoganDark avatar May 29 '19 08:05 LoganDark

I finally did it.

Filyus avatar May 30 '19 03:05 Filyus

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

LoganDark avatar May 30 '19 03:05 LoganDark

Workaround: you can upgrade send in your project, and live-server should use it. npm i [email protected] --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.

1j01 avatar Jun 24 '21 05:06 1j01