Deploying Blazor webassembly on Windows local server not working as well

36 views Asked by At

I've installed URL Rewrite module on a local server with Windows Server 2016 before deploying Blazor wasm.

I added this code after the _framework/blazor.webassembly.js script reference in the index.html page:

<script type="module">
     import { BrotliDecode } from './decode.min.js';
     Blazor.start({
         loadBootResource: function (type, name, defaultUri, integrity) {
             if (type !== 'dotnetjs' && location.hostname !== 'localhost' && type !== 'configuration') {
                 return (async function () {
                     const response = await fetch(defaultUri + '.br', { cache: 'no-cache' });
                     if (!response.ok) {
                         throw new Error(response.statusText);
                     }
                     const originalResponseBuffer = await response.arrayBuffer();
                     const originalResponseArray = new Int8Array(originalResponseBuffer);
                     const decompressedResponseArray = BrotliDecode(originalResponseArray);
                     const contentType = type ===
                         'dotnetwasm' ? 'application/wasm' : 'application/octet-stream';
                     return new Response(decompressedResponseArray,
                         { headers: { 'content-type': contentType } });
                 })();
             }
         }
     });
</script>

But after deploying it on the server it works on server as link of localhost "http://localhost:nnn"

When I get the application from a client by the ip of the server "http://xxx.xxx.xxx.xxx:nnn", I get this error

error in the client

How could I solve this problem? Please help

0

There are 0 answers