0
I’m trying to deploy angular application 8
When I use the command
ng build --prod --base-href /app/
When I try to run the application on localhost/app
The app does not load
On the console you have this message:
http://localhost/app/main-es2015.de53c17ebee928a1e2c9.js net::ERR_ABORTED 404 (Not Found)
But when I deploy it without the --prod
it runs the application, however, if I refresh the page, the server cannot find the page
I can only update the page if I deploy using the Hash strategy
providers: [
//{provide: LocationStrategy, useClass: HashLocationStrategy} //adicionar um # a url
]
[Edit]
I’m using Apache server 2.4
My file . htaccess inside the app folder (localhost/app) looks like this:
RewriteEngine On
# If an existing asset or directory is requested go to it as it is
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
# If the requested resource doesn't exist, use index.html
RewriteRule ^ /index.html
As documented
which server you are using?
– Eduardo Vargas
I used Apache server 2.4
– adventistaam
https://angular.io/guide/deployment#routed-apps-must-fallback-to-indexhtml take a look at this configuration of your htaccess, at least it will make sure that when you update it doesn’t lose the page
– Eduardo Vargas
That’s where I got the configuration
– adventistaam
tries Rewriterule /app/index.html
– Eduardo Vargas
It worked, buddy! That’s right. . htacess, now missing the --Prod
– adventistaam
Gave this here:
Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
when I used the--prod
– adventistaam
Try to see if this file that he is looking for actually exists on the server and the path is correct
– Eduardo Vargas
When I deploy without
--prod
the application runs normal... To provide the application with the production api address, I have to change the address onenvironment
and is already configured inenvironment.prod
– adventistaam
@Eduardovargas put your answer on the . htaccess I’m going to settle on the deploy with
--prod
.. You’ve helped a lot– adventistaam