I'm using the following code to server an Angular app.
package main
import (
"github.com/gorilla/mux"
"log"
"net/http"
)
func main() {
r := mux.NewRouter()
r.PathPrefix("/portals/").Handler(http.StripPrefix("/portals/", http.FileServer(http.Dir("./portals/"))))
r.PathPrefix("/dependencies/").Handler(http.StripPrefix("/dependencies/", http.FileServer(http.Dir("./dependencies/"))))
r.HandleFunc("/registeruser", UserRegistrationHandler)
r.HandleFunc("/deleteuser/{username}", DeleteUserHandler)
http.Handle("/", r)
log.Println("Listening...")
http.ListenAndServe(":8000", r)
}
If I navigate to http://localhost:8000/portals/ it's able to render the site correctly with all the dependencies.But http://localhost:8000/portals fails with 404 Not Found.
Similarly if I navigate to http://localhost:8000/portals/#login it works as expected.But if I navigate to http://localhost:8000/portals/login it gives 404.
Another thing I noticed is http://localhost:8000/portals/login url works if I navigate to it via a link inside the app(say login link). But if I type the url in the browser and hit enter it gives a 404.
What would be the missing part here?Am I handling the static content wrongly?
You need to enable html5mode
in angularjs