🐛 Bug fixes infinite redirecting
Some checks are pending
release-nightly / build-docker (push) Waiting to run

This commit is contained in:
LittleSheep 2024-01-26 16:04:34 +08:00
parent 302491741f
commit 2860542e44
3 changed files with 17 additions and 16 deletions

View File

@ -1,12 +1,12 @@
id = "example-region"
[[locations]]
id = "example-websocket"
host = ["localhost:8000"]
path = ["/ws"]
[[locations.destinations]]
id = "example-websocket-destination"
uri = "http://localhost:8765"
# [[locations]]
# id = "example-websocket"
# host = ["localhost:8000"]
# path = ["/ws"]
# [[locations.destinations]]
# id = "example-websocket-destination"
# uri = "http://localhost:8765"
# [[locations]]
# id = "example-warden"
@ -23,9 +23,9 @@ uri = "http://localhost:8765"
# environment = ["PUBLIC_CMS=https://smartsheep.studio"]
[[locations]]
id = "example-static"
id = "example"
host = ["localhost:8000"]
path = ["/"]
[[locations.destinations]]
id = "example-static-destination"
uri = "files://test/data"
id = "example-destination"
uri = "http://protocol.smartsheep.studio:20004"

View File

@ -9,7 +9,6 @@ import (
"github.com/gofiber/fiber/v2/utils"
"github.com/rs/zerolog/log"
"github.com/samber/lo"
"github.com/spf13/viper"
"github.com/valyala/fasthttp"
"io/fs"
"net/http"
@ -32,10 +31,11 @@ func makeUnifiedResponse(c *fiber.Ctx, dest *Destination) error {
}
func makeHypertextResponse(c *fiber.Ctx, dest *Destination) error {
timeout := time.Duration(viper.GetInt64("performance.network_timeout")) * time.Millisecond
return proxy.Do(c, dest.MakeUri(c), &fasthttp.Client{
ReadTimeout: timeout,
WriteTimeout: timeout,
limit := 60 * time.Millisecond
uri := dest.MakeUri(c)
return proxy.Do(c, uri, &fasthttp.Client{
ReadTimeout: limit,
WriteTimeout: limit,
})
}

View File

@ -75,9 +75,10 @@ func (v *Destination) MakeUri(ctx *fiber.Ctx) string {
path := string(ctx.Request().URI().Path())
hash := string(ctx.Request().URI().Hash())
protocol := v.GetProtocol()
uri, _ := v.GetRawUri()
return uri + path +
return protocol + "://" + uri + path +
lo.Ternary(len(queries) > 0, "?"+strings.Join(queries, "&"), "") +
lo.Ternary(len(hash) > 0, "#"+hash, "")
}