mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-13 05:12:50 +00:00
cors for image board
This commit is contained in:
1 parent
c956ea1239
commit
d7155e55d7
1 file changed
+23
-1
@@ -3,9 +3,15 @@ use actix_cors::Cors;
|
||||
use crate::util::netlify_branch_domain_matches::netlify_branch_domain_matches;
|
||||
|
||||
pub fn add_video_compositor(cors: Cors, _is_production: bool) -> Cors {
|
||||
cors.allowed_origin_fn(|origin, _req_head| {
|
||||
cors
|
||||
// Hypothetical domains
|
||||
.allowed_origin("https://memeboard.ai")
|
||||
.allowed_origin("https://dingboard.ai")
|
||||
// Netlify project
|
||||
.allowed_origin_fn(|origin, _req_head| {
|
||||
netlify_branch_domain_matches(origin, "storyteller-board.netlify.app")
|
||||
})
|
||||
// Local development
|
||||
.allowed_origin("http://localhost:5173/")
|
||||
}
|
||||
|
||||
@@ -17,6 +23,22 @@ mod tests {
|
||||
use crate::testing::assert_origin_invalid;
|
||||
use crate::testing::assert_origin_ok;
|
||||
|
||||
mod domains {
|
||||
use super::*;
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn memeboard() {
|
||||
let production_cors = build_cors_config(ServerEnvironment::Production);
|
||||
assert_origin_ok(&production_cors, "https://memeboard.ai").await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn dingboard() {
|
||||
let production_cors = build_cors_config(ServerEnvironment::Production);
|
||||
assert_origin_ok(&production_cors, "https://dingboard.ai").await;
|
||||
}
|
||||
}
|
||||
|
||||
mod netlify {
|
||||
use super::*;
|
||||
|
||||
|
||||
Reference in new issue
Block a user