I have a WebServer (CentOS) with Apache, it has a a Blazor WASP app, if the DocumentRoot
is set directly where the index.html is, the app works, but if it isn't, it will read the index.html and show the loading screen but wont load. To clarify:
Blazor app location: /var/www/sometestfolder/main/wwwroot
WORKS
- httpd.conf:
DocumentRoot "/var/www/sometestfolder/main/wwwroot"
- Site accessed via:
example.com
DOESN'T WORK:
- httpd.conf:
DocumentRoot "/var/www"
- Site accessed via:
example.com/sometestfolder/main/wwwroot
(shows the "Loading... An unhandled error has occurred. Reload " text of a blazor app but soesnt seem to be loaded as one since "An unhandled error has occurred" shouldn't be there.
QUESTION : Why doesn't the second case work? Is there a way for it to work or am I doing everything wrong?
I dont think I'm publishing the app correctly (ftp publish to the server, result being wwwroot folder and web.config file) and that leads to the app working witohut the need of any virtual host, microsoft manual states that a blazor app needs this virtual host to work:
<VirtualHost *:80>
ServerName www.example.com
ServerAlias *.example.com
DocumentRoot "/var/www/blazorapp"
ErrorDocument 404 /index.html
AddType application/wasm .wasm
AddType application/octet-stream .dll
<Directory "/var/www/blazorapp">
Options -Indexes
AllowOverride None
</Directory>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE application/octet-stream
AddOutputFilterByType DEFLATE application/wasm
<IfModule mod_setenvif.c>
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
ErrorLog /var/log/httpd/blazorapp-error.log
CustomLog /var/log/httpd/blazorapp-access.log common
source: https://learn.microsoft.com/es-es/aspnet/core/blazor/host-and-deploy/webassembly?view=aspnetcore-6.0
(Scroll down do "Apache")