mirror of
https://github.com/harness/drone.git
synced 2025-05-11 22:50:11 +08:00
CODE-688: All static assets must be served from the root path
This commit is contained in:
parent
2b6e75682d
commit
a8b48d228d
@ -11,6 +11,7 @@ import (
|
|||||||
"io/fs"
|
"io/fs"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -36,6 +37,7 @@ func Handler() http.HandlerFunc {
|
|||||||
// http.FileServer to always load the index.html
|
// http.FileServer to always load the index.html
|
||||||
// file if a directory path is being requested.
|
// file if a directory path is being requested.
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
// because this is a single page application,
|
// because this is a single page application,
|
||||||
// we need to always load the index.html file
|
// we need to always load the index.html file
|
||||||
// in the root of the project, unless the path
|
// in the root of the project, unless the path
|
||||||
@ -44,6 +46,9 @@ func Handler() http.HandlerFunc {
|
|||||||
// HACK: alter the path to point to the
|
// HACK: alter the path to point to the
|
||||||
// root of the project.
|
// root of the project.
|
||||||
r.URL.Path = "/"
|
r.URL.Path = "/"
|
||||||
|
} else {
|
||||||
|
// All static assets are served from the root path
|
||||||
|
r.URL.Path = "/" + path.Base(r.URL.Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable caching and sniffing via HTTP headers for UI main entry resources
|
// Disable caching and sniffing via HTTP headers for UI main entry resources
|
||||||
|
Loading…
Reference in New Issue
Block a user