Hola, recibo este error en el navegador de la consola en mi aplicación angular 8, veo las ventanas del navegador en blanco y aparece este error
Uncaught SyntaxError: Unexpected token '<'intento ejecutar mi compilación ng
ng build --base-href / --aot --prod ng build --base-href /my_app/ --aot --prod ng build --prod ng build --aot --prod --output-hashing nonenada funciona...
mi archivo de configuración de apache
<VirtualHost *:80> DocumentRoot "/var/www/html/MrpProy/my_app/dist/my_app/" ServerName mydomain.com <Directory /var/www/html/MrpProy/my_app/dist/my_app/> RewriteEngine on # Rewrite everything else to index.html to allow HTML5 state links RewriteRule ^ index.html [L] </Directory> </VirtualHost>como se soluciona esto?
Como dijo @MikeOne en los comentarios anteriores...
Probablemente también esté devolviendo el
index.htmlen las solicitudes de JavaScript.
debido a su configuración de Apache ...
# Rewrite everything else to index.html to allow HTML5 state links RewriteRule ^ index.html [L]
Esto literalmente reescribe todo (no solo "todo lo demás") en index.html . Por lo tanto, al solicitar anything.js cosa.js, el servidor responde con index.html . Entonces, sí, el navegador está tratando de analizar index.html como JavaScript.
Su configuración de Apache debería ser algo como esto, para evitar que las solicitudes de recursos estáticos se reescriban en index.html :
RewriteEngine on # Rewrite everything that does not look-like a file to index.html RewriteRule !\.\w{2,4}$ index.html [L]O, un poco menos eficiente (pero posiblemente más flexible):
# Rewrite everything that is not a file to index.html RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.html [L]