Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 5 error 404 when copying dist to webserver

I made a simple Angular 5 cover to say that I'm still constructing this website. ng serve works fine locally, but now I wanted to host this on my schools website here and I get all these 404 resources not found and all I did was copy whats in the dist/ folder after running ng build --prod to the www/ folder on the webserver.

It's angular 5 with this cli version:

 "@angular/cli": "~1.7.1",
"@angular/compiler-cli": "^5.2.0",

I tried to push another one to github-pages and this has the same problem githubpages the repo is repo but it's almost an empty repo.

like image 670
Burst of Ice Avatar asked Mar 12 '26 16:03

Burst of Ice


1 Answers

You need to add --base-href parameter when you build your application, like this:

ng build --prod --base-href /~320255eg/

Where /~320255eg/ represents the path to your application.

like image 83
Laiso Avatar answered Mar 15 '26 07:03

Laiso



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!