fix: setting Secure behind nginx

bug was due to having explicit 'serve --http=address' when running
behind nginx on NixOS server
So either a more complicated check was required, or just setting
Secure=true unconditionally.

This seems to be a better way, because Firefox already allows secure
cookies beng sent and received from localhost for dev purposes, and
Chromium does too
This commit is contained in:
efim
2023-10-09 04:50:33 +00:00
parent 2a3d00839f
commit a367ed9a34
3 changed files with 37 additions and 18 deletions

13
main.go
View File

@@ -2,8 +2,6 @@ package main
import (
"log"
"strings"
"github.com/pocketbase/pocketbase"
"sunshine.industries/auth-pocketbase-attempt/middleware"
"sunshine.industries/auth-pocketbase-attempt/pages"
@@ -12,13 +10,10 @@ import (
func main() {
app := pocketbase.New()
servedName := app.Settings().Meta.AppUrl
isTlsEnabled := strings.HasPrefix(servedName, "https://")
middleware.AddCookieSessionMiddleware(app, isTlsEnabled)
middleware.AddCookieSessionMiddleware(app)
pages.AddPageRoutes(app)
if err := app.Start(); err != nil {
log.Fatal(err)
}
if err := app.Start(); err != nil {
log.Fatal(err)
}
}