@@ -320,9 +320,9 @@ func FileServerMiddleware(next http.Handler) http.Handler {
320320 w .Header ().Set ("Server" , globalAppName ) // do not add version information
321321 basePath := GetSubPath ()
322322 switch {
323- case strings .HasPrefix (r .URL .Path , basePath + "/ ws" ):
323+ case strings .HasPrefix (r .URL .Path , basePath + "ws" ):
324324 serveWS (w , r )
325- case strings .HasPrefix (r .URL .Path , basePath + "/ api" ):
325+ case strings .HasPrefix (r .URL .Path , basePath + "api" ):
326326 next .ServeHTTP (w , r )
327327 default :
328328 buildFs , err := fs .Sub (portal_ui .GetStaticAssets (), "build" )
@@ -360,7 +360,7 @@ func handleSPA(w http.ResponseWriter, r *http.Request) {
360360 if v := r .URL .Query ().Get ("cp" ); v == "y" {
361361 if base := r .URL .Query ().Get ("cpb" ); base != "" {
362362 // make sure the subpath has a trailing slash
363- if ! strings .HasSuffix (base , basePath ) {
363+ if ! strings .HasSuffix (base , "/" ) {
364364 base = fmt .Sprintf ("%s/" , base )
365365 }
366366 basePath = base
@@ -441,7 +441,7 @@ func handleSPA(w http.ResponseWriter, r *http.Request) {
441441// wrapHandlerSinglePageApplication handles a http.FileServer returning a 404 and overrides it with index.html
442442func wrapHandlerSinglePageApplication (h http.Handler ) http.HandlerFunc {
443443 return func (w http.ResponseWriter , r * http.Request ) {
444- if r . URL . Path == GetSubPath () + "/" {
444+ if match , _ := regexp . MatchString ( fmt . Sprintf ( "^%s/?$" , GetSubPath ()), r . URL . Path ); match {
445445 handleSPA (w , r )
446446 return
447447 }
@@ -501,7 +501,7 @@ func replaceBaseInIndex(indexPageBytes []byte, basePath string) []byte {
501501 return indexPageBytes
502502 }
503503 indexPageStr := string (indexPageBytes )
504- newBase := fmt .Sprintf ("<base href=\" %s/ \" />" , basePath )
504+ newBase := fmt .Sprintf ("<base href=\" %s\" />" , basePath )
505505 indexPageStr = strings .Replace (indexPageStr , "<base href=\" /\" />" , newBase , 1 )
506506 indexPageBytes = []byte (indexPageStr )
507507
0 commit comments