feat: cors

This commit is contained in:
2022-05-02 22:27:27 +08:00
parent ff4b983ac3
commit 0fcb56c8a3
2 changed files with 10 additions and 0 deletions

View File

@@ -3,6 +3,8 @@ MAST_CLIENT="<your client id>"
MAST_SECRET="<your client key>"
MAST_SCOPE="read:accounts"
FRONTEND_WHITELIST="https://hole-thu.github.io"
DATABASE_URL="postgres://hole:hole_pass@localhost/hole_v2"
MIGRATION_DIRECTORY=migrations/postgres
REDIS_URL="redis://127.0.0.1:6379"

View File

@@ -12,6 +12,7 @@ extern crate log;
mod api;
mod cache;
mod cors;
mod db_conn;
mod libs;
#[cfg(feature = "mastlogin")]
@@ -98,6 +99,13 @@ async fn main() -> Result<(), rocket::Error> {
.manage(RandomHasher::get_random_one())
.manage(rmc)
.attach(Db::fairing())
.attach(cors::CORS {
whitelist: env::var("FRONTEND_WHITELIST")
.unwrap_or_default()
.split(',')
.map(|s| s.to_string())
.collect::<Vec<String>>(),
})
.launch()
.await
}