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
DocumentRoot "/var/www/sometestfolder/main/wwwroot"
example.com
DOESN'T WORK:
DocumentRoot "/var/www"
example.com/sometestfolder/main/wwwroot
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")
Any reference to other files (css, images, js, ...) in the index.html will be searched in directory "/var/www".
Exemple
DocumentRoot
defines the "virtual /" or the root of your web site files.
I would expect errors in your logs (Apache or application) indicating that it cannot find the files. You might need to increase logging (LogLevel) to get more details.