refactor: allow root domain app urls for testing

This commit is contained in:
Stavros
2026-03-29 20:27:09 +03:00
parent 0e4d8c6855
commit f65df872f0
2 changed files with 8 additions and 0 deletions

View File

@@ -13,6 +13,8 @@ BIN_NAME := tinyauth-$(GOARCH)
DEV_COMPOSE := $(shell test -f "docker-compose.test.yml" && echo "docker-compose.test.yml" || echo "docker-compose.dev.yml" )
PROD_COMPOSE := $(shell test -f "docker-compose.test.prod.yml" && echo "docker-compose.test.prod.yml" || echo "docker-compose.example.yml" )
.DEFAULT_GOAL := binary
# Deps
deps:
bun install --cwd frontend

View File

@@ -8,6 +8,7 @@ import (
"strings"
"github.com/steveiliop56/tinyauth/internal/config"
"github.com/steveiliop56/tinyauth/internal/utils/tlog"
"github.com/gin-gonic/gin"
"github.com/weppos/publicsuffix-go/publicsuffix"
@@ -28,6 +29,11 @@ func GetCookieDomain(u string) (string, error) {
parts := strings.Split(host, ".")
if len(parts) == 2 {
tlog.App.Warn().Msgf("Running on the root domain, cookies will be set for .%v", host)
return host, nil
}
if len(parts) < 3 {
return "", errors.New("invalid app url, must be at least second level domain")
}