Force HTTPS
Some checks failed
release-nightly / build-docker (push) Failing after 7s

This commit is contained in:
LittleSheep 2024-01-31 00:36:04 +08:00
parent 11cf35cf0d
commit ef10fab47d

View File

@ -26,6 +26,19 @@ func InitServer() *fiber.App {
BodyLimit: viper.GetInt("hypertext.limitation.max_body_size"),
})
if viper.GetBool("hypertext.force_https") {
app.Use(func(c *fiber.Ctx) error {
if !c.Secure() {
return c.Redirect(
strings.Replace(c.Request().URI().String(), "http", "https", 1),
fiber.StatusMovedPermanently,
)
}
return c.Next()
})
}
if viper.GetBool("telemetry.request_logging") {
app.Use(logger.New(logger.Config{
Output: log.Logger,