HTTP Response Header "Content-Type" configured incorrectly

Hello everyone,

I exported my WebGL app (Unity 2021.1.24f1) and it’s already on the Tomcat server but whenever the Unity loading screen is shown, there’s some type of warning above the logo in a yellow box (with a white border):

“Build/2.wasm” exists in the export. Is that something I have to change for the export or on the server? What exactly do I have to change? I found this and this but I’m not sure I understand what the message is asking of me or where to add stuff, tbh.

2 Likes

same here!

Bump… I have this issue too lol

I managed to fix it! Add the following to the “web.xml” file:

<mime-mapping>
    <extension>wasm</extension>
    <mime-type>application/wasm</mime-type>
</mime-mapping>

You might also need:

<mime-mapping>
    <extension>data</extension>
    <mime-type>application/octet-stream</mime-type>
</mime-mapping>
<mime-mapping>
    <extension>symbols.json</extension>
    <mime-type>application/octet-stream</mime-type>
</mime-mapping>
2 Likes

Thanks for your solution! But, where is the web.xml? I can’t find it in either my project or my build.

2 Likes

[quote=“Mashimaro7, post:5, topic: 864159, username:Mashimaro7”]
Thanks for your solution! But, where is the web.xml? I can’t find it in either my project or my build.
[/quote]The web.xml is a file on the server/in your server project that calls your Unity WebGL project.

1 Like

Ah, I got it. Sorry, don’t know much about WebGL, I’m not running it on a server, it’s for a client haha.

Thanks for the response

Hello, I am facing the same issue! I can’t find any web.xml file in my server folder. What have happen to my hosting? I use wordpress on hostinger server. I want to upload my WebGl to my hostinger server

2 Likes

Hello, unfortunately I have no real solution for the problem. But you can remove the error message that is displayed. To do this simply disable line 70 and 72 in the WebGL.loader.js file. This works with a development build.

      if (typeof message === 'string' && message.indexOf('wasm streaming compile failed') != -1) {
        if (message.toLowerCase().indexOf('mime') != -1) {
        //  showBanner('HTTP Response Header "Content-Type" configured incorrectly on the server for file ' + Module.codeUrl + ' , should be "application/wasm". Startup time performance will suffer.', 'warning');
        } else {
          //showBanner('WebAssembly streaming compilation failed! This can happen for example if "Content-Encoding" HTTP header is incorrectly enabled on the server for file ' + Module.codeUrl + ', but the file is not pre-compressed on disk (or vice versa). Check the Network tab in browser Devtools to debug server header configuration.', 'warning');
        }
      }

For a normal build delete or comment out the first if statement in WebGL.loader.js.
it is marked in bold in the code example below:

function createUnityInstance(e,r,n){function o(e,n){i**f(!o.aborted&&r.showBanner)return"error"==n&&(o.aborted=!0),r.showBanner(e,n);**switch(n){case"error":console.error(e);break;case"warning":console.warn(e);break;default:console.log(e)}}function t(e){var r=e.reason||e.error,n=r?r.toString():e.message||e.reason||“”,o=r&&r.stack?r.stack.toString():“”;if(o.startsWith(n)&&(o=o.substring(n.length)),n+=“\n”+o.trim(),n&&c.stackTraceRegExp&&c.stackTraceRegExp.test(n)){var t=e.filename||r&&(r.fileName||r.sourceURL)||“”,a=e.lineno||r&&…

1 Like

@jayray2000
No need to mess with Unity’s files, there already is a real solution in post #4.

That’s right, but I have no idea where to find the web.xml file or where to put it on my server… :wink:

[quote=“jayray2000, post:11, topic: 864159, username:jayray2000”]
That’s right, but I have no idea where to find the web.xml file or where to put it on my server… :wink:
[/quote]It should already be on the server. If you don’t know what you’re doing, then the last thing you should do is messing with Unity’s files and disabling the error won’t fix the underlying problem anyway.

Could you tell us where the ‘web.xml’ file is expected to be found on an Apache server? I am using shared hosting and familiar with updating .htaccess and .httpconf files but not web.xml files. I have been uploading WebGL builds to this particular server for years and never encountered this before doing a WebGL build with Unity 2021. I have contacted my webhost support chat and requested they update the ‘web.xml’ file and they said it does not exist.

EDIT: I added the following to the .htaccess file within the root of my project (where index.html is) and that resolved the issue - did not need to locate the web.xml.

AddType application/wasm wasm
15 Likes

I added the following to an .htaccess file (I created myself) within the root of my project (where index.html is) and that resolved the issue - did not need to locate the web.xml.

AddType application/wasm wasm
6 Likes

do you just create a blank .httaccess text file with that as the only line? I also have no web.xml file.

I did already have one for subdirectory settings but creating a new blank one should have the same result.

For anyone using Apache2, you can either use .htaccess as mentioned in post #14, but some apache installations don’t have .htaccess files enabled, like mine.

I added AddType application/wasm .wasm to /etc/apache2/ mods-enabled/mime.conf

This worked for Apache/2.2.22 (Ubuntu)

2 Likes

For me .htaccess did work and couldn’t find web.xml but adding a file named web.config to the directory with index.html worked, the content is;

Just do that:

  1. Create the .htaccess file with the required rules
    Unity - Manual: Server configuration code samples

  2. Put the .htaccess in the root (where is index.html), NOT in the “build” folder (as told by Unity docs)

  3. Add the following rule to the .htaccess
    AddType application/wasm .wasm

Now it should work

4 Likes

not work, not work, not work :frowning: