mirror of
https://github.com/lifegpc/pixiv_downloader.git
synced 2026-06-06 05:49:01 +08:00
Add new settings cors-allow-all
This commit is contained in:
@@ -74,6 +74,18 @@ impl OptHelper {
|
||||
self._cors_entries.get_ref().clone()
|
||||
}
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
pub fn cors_allow_all(&self) -> bool {
|
||||
if self.settings.get_ref().have_bool("cors-allow-all") {
|
||||
return self
|
||||
.settings
|
||||
.get_ref()
|
||||
.get_bool("cors-allow-all")
|
||||
.unwrap_or(false);
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
#[cfg(feature = "db")]
|
||||
/// Return the config of the database
|
||||
pub fn db(&self) -> PixivDownloaderDbConfig {
|
||||
|
||||
@@ -417,7 +417,7 @@ impl Default for CorsContext {
|
||||
fn default() -> Self {
|
||||
let helper = get_helper();
|
||||
Self {
|
||||
allow_all: false,
|
||||
allow_all: helper.cors_allow_all(),
|
||||
entries: helper.cors_entries(),
|
||||
hosts: Vec::new(),
|
||||
}
|
||||
|
||||
@@ -62,6 +62,8 @@ pub fn get_settings_list() -> Vec<SettingDes> {
|
||||
#[cfg(feature = "ugoira")]
|
||||
SettingDes::new("ugoira-max-fps", gettext("The max fps when converting ugoira(GIF) to video."), JsonValueType::Number, Some(check_ugoira_max_fps)).unwrap(),
|
||||
SettingDes::new("fanbox-page-number", gettext("Use page number for pictures' file name in fanbox."), JsonValueType::Boolean, None).unwrap(),
|
||||
#[cfg(feature = "server")]
|
||||
SettingDes::new("cors-allow-all", gettext("Whether to allow all domains to send CORS requests."), JsonValueType::Boolean, None).unwrap(),
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user