How to serve angular with golang?


I am trying it using http.FileServe providing the directory of angular app. But instead I get the list of files in that folder. I am using gorilla mux package.

If it is for a simple html file it does work but not for angular app.

router := mux.NewRouter()

This lists all files in directory in ./static/src/app when went to that url. How should I correctly do it ?


The Angular application is most likely served via its own NodeJS server (by default on port 4200 if I remember). You need to run ng build if you’ve created the app via Angular cli.

Afterwards, serve the index.html file inside the /dist folder which’ll be created upon running ng build. That file contains the minified, bundled JS which can be served via any webserver.

Answered By – Milan Velebit

Answer Checked By – Gilberto Lyons (GoLangFix Admin)

Leave a Reply

Your email address will not be published.