How do I publish an Angular CLI project to my server?

Asked

Viewed 838 times

1

I have a project in Angularjs running localhost perfectly.
I’m trying to host on the server "HOSTGATOR" and I’m not succeeding.
I’m generating the build with the Angular CLI and Hosting the Dir "Dist" in "www". When trying to access the index.html the following errors occur:

Falha no carregamento do <script> com a fonte “http://site.com.br/runtime.a66f828dca56eeb90e02.js”.<br>
Falha no carregamento do <script> com a fonte “http://site.com.br/polyfills.2f4a59095805af02bd79.js”.<br>
Falha no carregamento do <script> com a fonte “http://site.com.br/main.5d52293f160730f348fe.js”.

Then I play all the files, including the index.html, at www root. So when accessing index.html presents only the welcome page of Angular. "Welcome to app!"

I wonder if someone could help me?

Thank you...

1 answer

1

First check that when you give the build your href is according to what you expect. If it is direct from the site for example

site.com.br   ## não precisa do href

if you want to do something like

site.com.br/app  ## use ng build --base-href=/app

Another important point is that Voce has to configure its server to redirect all routes to index.html. In the documentation has explaining most popular servers.

https://angular.io/guide/deployment#routed-apps-must-fallback-to-indexhtml

  • Eduardo, thank you so much for answering! I sent an email to my server, because I still have doubts about the settings.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.