-
Notifications
You must be signed in to change notification settings - Fork 491
Add cors debug mode #5955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cors debug mode #5955
Conversation
quickwit/quickwit-serve/src/rest.rs
Outdated
| } | ||
|
|
||
| fn build_cors(cors_origins: &[String]) -> CorsLayer { | ||
| let debug_mode = quickwit_common::get_bool_from_env("QW_ENABLE_DEBUG_CORS", false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| let debug_mode = quickwit_common::get_bool_from_env("QW_ENABLE_DEBUG_CORS", false); | |
| let debug_mode = quickwit_common::get_bool_from_env("QW_ENABLE_CORS_DEBUG", false); |
quickwit/quickwit-serve/src/rest.rs
Outdated
| fn build_cors(cors_origins: &[String]) -> CorsLayer { | ||
| let debug_mode = quickwit_common::get_bool_from_env("QW_ENABLE_DEBUG_CORS", false); | ||
| if debug_mode { | ||
| info!("DEBUG CORS is enabled, localhost and 127.0.0.1 origins will be allowed"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| info!("DEBUG CORS is enabled, localhost and 127.0.0.1 origins will be allowed"); | |
| info!("CORS debug mode is enabled, localhost and 127.0.0.1 origins will be allowed"); |
quickwit/quickwit-serve/src/rest.rs
Outdated
| if debug_mode { | ||
| info!("DEBUG CORS is enabled, localhost and 127.0.0.1 origins will be allowed"); | ||
| return CorsLayer::new() | ||
| .allow_methods([Method::GET]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a feeling you will need more methods eventually: wanna add POST, PUT, PATCH, DELETE?
quickwit/quickwit-serve/src/rest.rs
Outdated
| return CorsLayer::new() | ||
| .allow_methods([Method::GET]) | ||
| .allow_origin(AllowOrigin::predicate(|origin, _parts| { | ||
| origin.as_bytes().starts_with(b"https://localhost:") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: easier to extend in the future
| origin.as_bytes().starts_with(b"https://localhost:") | |
| [b"https://localhost:", b"https://127.0.0.1:"] | |
| .iter() | |
| .any(|prefix| origin.as_bytes().starts_with(*prefix)) |
Description
When
QW_ENABLE_CORS_DEBUG=true, the originslocalhost:*and127.0.0.1:*will be allowedHow was this PR tested?
make test-all