fix: cors / otlp should be applied on all serve endpoints (#839)

release-fix-intellij-update-support-version-range
Meng Zhang 2023-11-19 13:47:23 -08:00 committed by GitHub
parent 54b146e9e9
commit b56ad6eda9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -119,6 +119,10 @@ pub async fn main(config: &Config, args: &ServeArgs) {
#[cfg(not(feature = "ee"))]
let app = app.fallback(|| async { axum::response::Redirect::permanent("/swagger-ui") });
let app = app
.layer(CorsLayer::permissive())
.layer(opentelemetry_tracing_layer());
let address = SocketAddr::from((Ipv4Addr::UNSPECIFIED, args.port));
info!("Listening at {}", address);
@ -224,8 +228,7 @@ async fn api_router(
for router in routers {
root = root.merge(router);
}
root.layer(CorsLayer::permissive())
.layer(opentelemetry_tracing_layer())
root
}
fn start_heartbeat(args: &ServeArgs) {

View File

@ -6,9 +6,11 @@ use std::{
use anyhow::Result;
use axum::{routing, Router};
use axum_tracing_opentelemetry::opentelemetry_tracing_layer;
use clap::Args;
use hyper::Server;
use tabby_webserver::api::{tracing_context, HubClient, WorkerKind};
use tower_http::cors::CorsLayer;
use tracing::{info, warn};
use crate::{
@ -87,6 +89,10 @@ pub async fn main(kind: WorkerKind, args: &WorkerArgs) {
WorkerKind::Chat => make_chat_route(context, args).await,
};
let app = app
.layer(CorsLayer::permissive())
.layer(opentelemetry_tracing_layer());
let address = SocketAddr::from((Ipv4Addr::UNSPECIFIED, args.port));
info!("Listening at {}", address);