Home >

SOLVED: Failed to load module script: Expected a JavaScript-or-Wasm module script

SOLVED: Failed to load module script: Expected a JavaScript-or-Wasm module script
Waktu mencoba sample code PDF.JS /web/viewer.html menggunakan PHP di Apache web server saya temukan error sebagai berikut:

Failed to load module script: Expected a JavaScript-or-Wasm module script but the server responded with a MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec

Dari web browser console kita bisa lihat code javascript error saat membuka file .mjs. Web server tidak memberikan return MIME-type yang sesuai untuk file ini.

Solusinya


1. Buka file Apache configuration httpd.conf

2. Cari addtype. Biasanya kita bisa temukan di dalam section <IfModule mime_module>

3. Selanjutnya dalam section <IfModule mime_module> kita tambahkan text berikut:



Sekedar ilustrasi agar lebih jelas. Berikut contoh capture AddType baru yang harus kita tambahkan:

SOLVED: Failed to load module script: Expected a JavaScript-or-Wasm module script

4. Save file

5. Restart Apache web server. Selesai
Share To:
X
X
Copy Link