From 433b8b9115e81aac364ea7261ccfdfaa5652c948 Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 10 Jun 2025 20:43:13 +0200 Subject: [PATCH] feat: enable cors by default for desktop app (#904) --- config-raw.json | 9 ++++++--- pkg/config/config.go | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/config-raw.json b/config-raw.json index 27b5430f6..ed451a8ba 100644 --- a/config-raw.json +++ b/config-raw.json @@ -290,15 +290,18 @@ "children": [ { "key": "enable", - "default_value": "false", - "comment": "Whether to enable or disable cors headers.\nNote: If you want to put the frontend and the api on separate domains or ports, you will need to enable this.\nOtherwise the frontend won't be able to make requests to the api through the browser." + "default_value": "true", + "comment": "Whether to enable or disable cors headers.\nBy default, this is enabled only for requests from the desktop application running on localhost.\nNote: If you want to put the frontend and the api on separate domains or ports, you will need to adjust this setting accordingly." }, { "key": "origins", "comment": "A list of origins which may access the api. These need to include the protocol (`http://` or `https://`) and port, if any.", "children": [ { - "default_value": "*" + "default_value": "http://127.0.0.1:*" + }, + { + "default_value": "http://localhost:*" } ] }, diff --git a/pkg/config/config.go b/pkg/config/config.go index dcd498a37..d135be288 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -421,8 +421,8 @@ func InitDefaultConfig() { FilesBasePath.setDefault("files") FilesMaxSize.setDefault("20MB") // Cors - CorsEnable.setDefault(false) - CorsOrigins.setDefault([]string{"*"}) + CorsEnable.setDefault(true) + CorsOrigins.setDefault([]string{"http://127.0.0.1:*", "http://localhost:*"}) CorsMaxAge.setDefault(0) // Migration MigrationTodoistEnable.setDefault(false)