mirror of
https://codeberg.org/shroff/phylum.git
synced 2026-01-05 11:10:47 -06:00
[server] Only serve static files if path doesn't match api, publinks, or webdav
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"net/http"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/fvbock/endless"
|
||||
@@ -77,7 +78,11 @@ func setupWebApp(r gin.IRoutes, webAppSrcDir string) {
|
||||
indexFilePath := path.Join(webAppSrcDir, "index.html")
|
||||
|
||||
staticFileHandler := func(c *gin.Context) {
|
||||
if c.Request.Method == "GET" {
|
||||
path := c.Request.URL.Path
|
||||
if c.Request.Method == "GET" &&
|
||||
!strings.HasPrefix(path, "/api") &&
|
||||
!strings.HasPrefix(path, Cfg.WebDAVPath) &&
|
||||
!strings.HasPrefix(path, Cfg.PublinkPath) {
|
||||
c.Writer.Header().Set("Cross-Origin-Embedder-Policy", "credentialless")
|
||||
c.Writer.Header().Set("Cross-Origin-Opener-Policy", "same-origin")
|
||||
if fs.Exists("/", c.Request.URL.Path) {
|
||||
|
||||
Reference in New Issue
Block a user