very permissive cors policy

This commit is contained in:
Bryan Stitt 2022-09-25 04:26:13 +00:00
parent 2c69b0ce9a
commit 7ed7f96a2f
3 changed files with 9 additions and 1 deletions

View File

@ -390,3 +390,7 @@ in another repo: event subscriber
- [ ] Ulid instead of Uuid for database ids
- might have to use Uuid in sea-orm and then convert to Ulid on display
- [ ] emit stat when an IP/key goes over rate limits
- [ ] readme command should run create_user commands via docker-compose
- [ ] helper for UUID <-> ULID
- [ ] Wrapping extractors in Result makes them optional and gives you the reason the extraction failed
- [ ] save errors if there is a cache hit?

View File

@ -65,8 +65,9 @@ tokio = { version = "1.21.1", features = ["full", "tracing"] }
tokio-stream = { version = "0.1.10", features = ["sync"] }
toml = "0.5.9"
tower = "0.4.13"
# TODO: i don't think we need this. we can use it from tower-http instead. though this seems to use ulid and not uuid?
tower-request-id = "0.2.0"
tower-http = { version = "0.3.4", features = ["trace"] }
tower-http = { version = "0.3.4", features = ["cors", "trace"] }
tracing = "0.1.36"
# TODO: tracing-subscriber has serde and serde_json features that we might want to use
tracing-subscriber = { version = "0.3.15", features = ["env-filter", "parking_lot"] }

View File

@ -15,6 +15,7 @@ use axum::{
};
use std::net::SocketAddr;
use std::sync::Arc;
use tower_http::cors::CorsLayer;
use tower_http::trace::TraceLayer;
use tower_request_id::{RequestId, RequestIdLayer};
use tracing::{error_span, info};
@ -73,6 +74,8 @@ pub async fn serve(port: u16, proxy_app: Arc<Web3ProxyApp>) -> anyhow::Result<()
.layer(Extension(proxy_app))
// add the request id to our tracing logs
.layer(request_tracing_layer)
// handle cors
.layer(CorsLayer::very_permissive())
// create a unique id for each request
.layer(RequestIdLayer)
// 404 for any unknown routes