fix: always add public url to allowed cors origins

This fixes a bug where it was not possible to do anything because the public url was not allowed by default for CORS requests.

Regression from 433b8b9115

Resolves https://github.com/go-vikunja/vikunja/issues/916
This commit is contained in:
kolaente
2025-06-11 14:27:32 +02:00
parent efb6ccf3e1
commit 842e7f524b
2 changed files with 4 additions and 0 deletions

View File

@@ -599,6 +599,9 @@ func InitConfig() {
if DefaultSettingsTimezone.GetString() == "" {
DefaultSettingsTimezone.Set(ServiceTimeZone.GetString())
}
publicURL := strings.TrimSuffix(ServicePublicURL.GetString(), "/")
CorsOrigins.Set(append(CorsOrigins.GetStringSlice(), publicURL))
}
func random(length int) (string, error) {

View File

@@ -182,6 +182,7 @@ func RegisterRoutes(e *echo.Echo) {
// CORS
if config.CorsEnable.GetBool() {
log.Debugf("CORS enabled with origins: %s", strings.Join(config.CorsOrigins.GetStringSlice(), ", "))
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
AllowOrigins: config.CorsOrigins.GetStringSlice(),
MaxAge: config.CorsMaxAge.GetInt(),