Search code examples
angularapacheproduction

Trouble with my angular project and my Apache Server



Look, i recently finished my project and went happy to send it to my Apache server.

My Apache server has the standard folder structure www as the source and inside of it you put you files.

I ran the command in my project: ng build --prod, and gave me the following files: my folder structure

So i copied the content of the dist file and paste it in the path: ./www/test/FitProject in my Apache folder and ran my server.
But the console hitted me with an error saying:

  1. localhost:8080/Polyfills.js error 404, this file wasn't found
  2. localhost:8080/Runtime.js error 404, this file wasn't found
  3. localhost:8080/styles.css error 404, this file wasn't found

So i tought, maybe it is searching for these files in the source folder(www) so i copied these files and paste it in the www folder and work out just fine.

So what can i do to stop this error and tells to the angular project to look for these files inside it's own folder, not in www ?


Solution

  • You need to set a option --base-href when build a project.

    ng build --prod --base-href /test/FitProject/