Importing WASM from a express server

303 views Asked by At

recently I've been coding in Rust WASM and compiling using wasm pack. When I had finished coding, I put the compiled files into my static folder, (I can confirm that they are static), and tried to import them in my HTML file. I keep getting this error: err, why does this crap hate me

afterwards, I checked the requests, and found this err 2, why does it say i have the content type of application/wasm?

I am very confused on why i get a invalid mime type when in the request it clearly says that the mimetype is correct. After searching around on github, someone else had this same problem. But this was a older post from 2018 and they said it was coming out in a newer version, the version, I had installed already. https://github.com/expressjs/express/issues/3589

Here is my rust code:

extern crate wasm_bindgen;
use wasm_bindgen::prelude::*;
use web_sys::*;


#[wasm_bindgen]
extern "C" {
    #[wasm_bindgen(js_namespace = console)]
    fn log(s: &str);
}


#[wasm_bindgen]
pub fn hello_world() {
    log("Hello, this is from Rust WASM");
}

and my HTML code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>epic gam</title>
    <link href="/static/css/styles.css" rel="stylesheet">
</head>
<body>
    <script src="/socket.io/socket.io.js"></script>
    <script src="/static/js/third-party/jquery.slim.js"></script>
    <!-- <script src="/static/js/bundle.js?version=0.0.1"></script> -->
    <script src="/static/js/game.js"></script>
    <script type="module" src="/static/wasm/wildz.js"></script>
</body>
</html>

Im confused on why this doesnt work, and would appreciate some help.

Thanks in advance.

0

There are 0 answers