mirror of
https://github.com/LemmyNet/lemmy
synced 2024-11-10 15:04:14 +00:00
parent
6840fd64f9
commit
084f603745
1 changed files with 11 additions and 7 deletions
18
src/lib.rs
18
src/lib.rs
|
@ -155,13 +155,17 @@ pub async fn start_lemmy_server() -> Result<(), LemmyError> {
|
||||||
|
|
||||||
// Create Http server with websocket support
|
// Create Http server with websocket support
|
||||||
HttpServer::new(move || {
|
HttpServer::new(move || {
|
||||||
let cors_config = if cfg!(debug_assertions) {
|
let cors_origin = std::env::var("LEMMY_CORS_ORIGIN");
|
||||||
Cors::permissive()
|
let cors_config = match (cors_origin, cfg!(debug_assertions)) {
|
||||||
} else {
|
(Ok(origin), false) => Cors::default()
|
||||||
let cors_origin = std::env::var("LEMMY_CORS_ORIGIN").unwrap_or("http://localhost".into());
|
.allowed_origin(&origin)
|
||||||
Cors::default()
|
.allowed_origin(&settings.get_protocol_and_hostname()),
|
||||||
.allowed_origin(&cors_origin)
|
_ => Cors::default()
|
||||||
.allowed_origin(&settings.get_protocol_and_hostname())
|
.allow_any_origin()
|
||||||
|
.allow_any_method()
|
||||||
|
.allow_any_header()
|
||||||
|
.expose_any_header()
|
||||||
|
.max_age(3600),
|
||||||
};
|
};
|
||||||
|
|
||||||
let app = App::new()
|
let app = App::new()
|
||||||
|
|
Loading…
Reference in a new issue