feat(cors): remove default value for BICHON_CORS_ORIGINS and allow all origins when unset

- Changed behavior so that when BICHON_CORS_ORIGINS is not configured, CORS now allows any origin.
- Added debug logging to print incoming Origin and configured origins to help users diagnose CORS misconfiguration issues.
This commit is contained in:
rustmailer
2025-12-07 00:03:21 +08:00
parent c90a2d552d
commit c00ffe8d11
2 changed files with 33 additions and 18 deletions
+1 -3
View File
@@ -16,7 +16,6 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
use clap::{builder::ValueParser, Parser, ValueEnum};
use std::{collections::HashSet, env, fmt, path::PathBuf, sync::LazyLock};
@@ -77,7 +76,6 @@ pub struct Settings {
/// CORS allowed origins (default: "*")
#[clap(
long,
default_value = "http://localhost:5173, http://localhost:15630, *",
env,
help = "Set the allowed CORS origins (comma-separated list, e.g., \"https://example.com, https://another.com\")",
value_parser = ValueParser::new(|s: &str| -> Result<HashSet<String>, String> {
@@ -88,7 +86,7 @@ pub struct Settings {
Ok(set)
})
)]
pub bichon_cors_origins: HashSet<String>,
pub bichon_cors_origins: Option<HashSet<String>>,
/// CORS max age in seconds (default: 86400)
#[clap(