mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-03 17:08:13 +00:00
cors for video board
This commit is contained in:
1 parent
40a13182f7
commit
bdbedc56ed
3 files changed
+53
-2
No files matched your search
@@ -1,5 +1,6 @@
|
||||
pub (crate) mod development_only;
|
||||
pub (crate) mod fakeyou;
|
||||
pub (crate) mod storyteller_studio;
|
||||
pub (crate) mod legacy;
|
||||
pub (crate) mod storyteller;
|
||||
pub (crate) mod storyteller;
|
||||
pub (crate) mod storyteller_studio;
|
||||
pub (crate) mod video_compositor;
|
||||
@@ -0,0 +1,48 @@
|
||||
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| {
|
||||
netlify_branch_domain_matches(origin, "storyteller-board.netlify.app")
|
||||
})
|
||||
.allowed_origin("http://localhost:5173/")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use reusable_types::server_environment::ServerEnvironment;
|
||||
|
||||
use crate::cors::build_cors_config;
|
||||
use crate::testing::assert_origin_invalid;
|
||||
use crate::testing::assert_origin_ok;
|
||||
|
||||
mod netlify {
|
||||
use super::*;
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn netlify_main() {
|
||||
let production_cors = build_cors_config(ServerEnvironment::Production);
|
||||
assert_origin_ok(&production_cors, "https://storyteller-board.netlify.app").await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn netlify_branch_deploy() {
|
||||
let production_cors = build_cors_config(ServerEnvironment::Production);
|
||||
assert_origin_ok(&production_cors, "https://test--storyteller-board.netlify.app").await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn netlify_deploy_preview() {
|
||||
let production_cors = build_cors_config(ServerEnvironment::Production);
|
||||
assert_origin_ok(&production_cors, "https://deploy-preview-123--storyteller-board.netlify.app").await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn invalid_netlify_preview_deploy() {
|
||||
let production_cors = build_cors_config(ServerEnvironment::Production);
|
||||
assert_origin_invalid(&production_cors, "https://storyteller-board--unrelated.netlify.app").await;
|
||||
assert_origin_invalid(&production_cors, "https://deploy-preview-123--unrelated.netlify.app").await;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ use crate::configs::fakeyou::{add_fakeyou, add_fakeyou_dev_proxy};
|
||||
use crate::configs::storyteller_studio::add_storyteller_studio;
|
||||
use crate::configs::legacy::{add_legacy_storyteller_stream, add_legacy_trumped, add_legacy_vocodes, add_power_stream};
|
||||
use crate::configs::storyteller::{add_storyteller, add_storyteller_dev_proxy};
|
||||
use crate::configs::video_compositor::add_video_compositor;
|
||||
|
||||
/// Return cors config for FakeYou / Vocodes / OBS / local development
|
||||
pub fn build_cors_config(server_environment: ServerEnvironment) -> Cors {
|
||||
@@ -35,6 +36,7 @@ fn do_build_cors_config(is_production: bool) -> Cors {
|
||||
cors = add_storyteller(cors, is_production);
|
||||
cors = add_storyteller_dev_proxy(cors, is_production);
|
||||
cors = add_storyteller_studio(cors, is_production);
|
||||
cors = add_video_compositor(cors, is_production);
|
||||
|
||||
// Legacy
|
||||
cors = add_legacy_trumped(cors, is_production);
|
||||
|
||||
Reference in new issue
Block a user