简体   繁体   中英

Load Angular2 Bootstrap template ng2-admin on Go server : download fail

I am new to this forum and a newbie in Angular2 and Golang . My issue is that I would like to try out a template on a Go server.

So, I created a main.go file containing this main() function :

func main() {
    r := mux.NewRouter()
    p := http.StripPrefix("/", http.FileServer(http.Dir("./src/")))
    n := http.StripPrefix("/config", http.FileServer(http.Dir("./config/")))
    r.PathPrefix("/config/").Handler(n)
    r.PathPrefix("/").Handler(p)
    fmt.Printf("Starting server on :33166 \n")
    http.ListenAndServe(":33166", r)
}

and run go run main.go on the project directory, but its fails in this request

GET http://127.0.0.1:33166/webpack-dev-server.js

It might be very simple, but I couldnot figure it out. So, any idea to how I'm able run the project on server would be appreciated. Thanks.

According to the ng2-admin installation guidelines , if you want to use ng2-admin with another backend (golang in your case), you need a release build using the following command:

npm run prebuild:prod && npm run build:prod

From installation guidelines:

This will clear up your dist folder (where release files are located), generate release build (...). Now you can copy the sources from a dist folder and use it with any backend framework or simply put it under some web server.

EDIT: Thanks to @PatrickWalker for his comments.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM