fix: cors / otlp should be applied on all serve endpoints (#839)
parent
54b146e9e9
commit
b56ad6eda9
|
|
@ -119,6 +119,10 @@ pub async fn main(config: &Config, args: &ServeArgs) {
|
||||||
#[cfg(not(feature = "ee"))]
|
#[cfg(not(feature = "ee"))]
|
||||||
let app = app.fallback(|| async { axum::response::Redirect::permanent("/swagger-ui") });
|
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));
|
let address = SocketAddr::from((Ipv4Addr::UNSPECIFIED, args.port));
|
||||||
info!("Listening at {}", address);
|
info!("Listening at {}", address);
|
||||||
|
|
||||||
|
|
@ -224,8 +228,7 @@ async fn api_router(
|
||||||
for router in routers {
|
for router in routers {
|
||||||
root = root.merge(router);
|
root = root.merge(router);
|
||||||
}
|
}
|
||||||
root.layer(CorsLayer::permissive())
|
root
|
||||||
.layer(opentelemetry_tracing_layer())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn start_heartbeat(args: &ServeArgs) {
|
fn start_heartbeat(args: &ServeArgs) {
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,11 @@ use std::{
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use axum::{routing, Router};
|
use axum::{routing, Router};
|
||||||
|
use axum_tracing_opentelemetry::opentelemetry_tracing_layer;
|
||||||
use clap::Args;
|
use clap::Args;
|
||||||
use hyper::Server;
|
use hyper::Server;
|
||||||
use tabby_webserver::api::{tracing_context, HubClient, WorkerKind};
|
use tabby_webserver::api::{tracing_context, HubClient, WorkerKind};
|
||||||
|
use tower_http::cors::CorsLayer;
|
||||||
use tracing::{info, warn};
|
use tracing::{info, warn};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
@ -87,6 +89,10 @@ pub async fn main(kind: WorkerKind, args: &WorkerArgs) {
|
||||||
WorkerKind::Chat => make_chat_route(context, args).await,
|
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));
|
let address = SocketAddr::from((Ipv4Addr::UNSPECIFIED, args.port));
|
||||||
info!("Listening at {}", address);
|
info!("Listening at {}", address);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue