Skip to content

Commit 50f0620

Browse files
authored
Mirror CORS request and allow credentials (#541)
Will follow with a separate PR to move this to developer mode.
1 parent 6707836 commit 50f0620

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

server/src/handlers/livetail.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use arrow_flight::{
3535
HandshakeResponse, PutResult, SchemaResult, Ticket,
3636
};
3737
use tonic_web::GrpcWebLayer;
38-
use tower_http::cors::{Any, CorsLayer};
38+
use tower_http::cors::{AllowHeaders, AllowMethods, AllowOrigin, CorsLayer};
3939

4040
use crate::livetail::{Message, LIVETAIL};
4141
use crate::metadata::STREAM_INFO;
@@ -175,11 +175,10 @@ pub fn server() -> impl Future<Output = Result<(), Box<dyn std::error::Error + S
175175
let svc = FlightServiceServer::new(service);
176176

177177
let cors = CorsLayer::new()
178-
// allow `GET` and `POST` when accessing the resource
179-
.allow_methods(Any)
180-
.allow_headers(Any)
181-
.allow_origin(Any);
182-
// allow requests from any origin
178+
.allow_methods(AllowMethods::mirror_request())
179+
.allow_headers(AllowHeaders::mirror_request())
180+
.allow_origin(AllowOrigin::mirror_request())
181+
.allow_credentials(true);
183182

184183
Server::builder()
185184
.accept_http1(true)

0 commit comments

Comments
 (0)