This commit is contained in:
2026-08-18 22:55:45 +02:00
parent 7b63911a7d
commit e5c5d7265a
2 changed files with 12 additions and 3 deletions
+11 -2
View File
@@ -14,7 +14,10 @@ use axum::{
response::Response,
routing::{any, get},
};
use tower_http::services::ServeFile;
use tower_http::{
cors::{Any, CorsLayer},
services::ServeFile,
};
use crate::server::Server;
@@ -22,11 +25,17 @@ use crate::server::Server;
async fn main() -> anyhow::Result<()> {
let server = Server::new().await?;
let cors = CorsLayer::new()
.allow_origin(Any)
.allow_methods(Any)
.allow_headers(Any);
let app = Router::new()
.route("/meta", get(meta))
.route("/", any(ws_handler))
.route_service("/icon", ServeFile::new("./icon.png"))
.with_state(server.clone());
.with_state(server.clone())
.layer(cors);
let listener = tokio::net::TcpListener::bind(SocketAddr::new(
IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)),