Skip to content

Commit

Permalink
Mirror CORS request and allow credentials (#541)
Browse files Browse the repository at this point in the history
Will follow with a separate PR to move this to 
developer mode.
  • Loading branch information
trueleo authored Oct 26, 2023
1 parent 6707836 commit 50f0620
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions server/src/handlers/livetail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use arrow_flight::{
HandshakeResponse, PutResult, SchemaResult, Ticket,
};
use tonic_web::GrpcWebLayer;
use tower_http::cors::{Any, CorsLayer};
use tower_http::cors::{AllowHeaders, AllowMethods, AllowOrigin, CorsLayer};

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

let cors = CorsLayer::new()
// allow `GET` and `POST` when accessing the resource
.allow_methods(Any)
.allow_headers(Any)
.allow_origin(Any);
// allow requests from any origin
.allow_methods(AllowMethods::mirror_request())
.allow_headers(AllowHeaders::mirror_request())
.allow_origin(AllowOrigin::mirror_request())
.allow_credentials(true);

Server::builder()
.accept_http1(true)
Expand Down

0 comments on commit 50f0620

Please sign in to comment.