emscripten-core / emscripten-core/emscripten
Failed to load resource
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
Please include the following in your bug report:
**Version of emscripten/emsdk:**
```console
$ emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 4.0.5-git (53b38d0c6f9fce1b62c55a8012bc6477f7a42711)
clang version 21.0.0git
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: C:/msys64/clang64/opt/emscripten-llvm/bin
```
**Failing command line in full:**
I was just customize [Using files](https://emscripten.org/docs/getting_started/Tutorial.html#using-files) example
from `Emscripten Tutorial` page:
```
$ mkdir -p out/static
$ ./emcc test/hello_world_file.cpp -o out/static/hello.mjs --preload-file test/hello_world_file.txt
$ cat > out/index.html << EOL
import initModule from './static/hello.mjs';
initModule({
print: (text) => { document.body.innerText += text + '\n'; }
});
EOL
$ ./emrun out/index.html
```
Failure from browser console:
```console
Failed to load resource: the server responded with a status of 404 (File not found: /out/hello.data)
```
Module `hello.mjs` search `hello.data` in `out` subdirectory (local webserver root). But `hello.mjs` sould search `hello.data` from `./static/` supdirecotry where `hello.mjs` hosted himself.
Then we mode `hello.data` to `out` from `out/static` and run again:
```console
$ mv out/static/hello.data out/
$ ./emrun out/index.html
```
And see text in browser:
```txt
==
This data has been read from a file.
The file is readable as if it were at the same location in the filesystem, including directories, as in the local filesystem where you compiled the source.
==
```
Contributor guide
Assessment
This issue has not been assessed yet.