Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ once_cell = "1.21"
axum = { version = "0.8", features = ["ws", "multipart"] }
axum-server = { version = "0.8", features = ["tls-rustls-no-provider"] }
rustls = { version = "0.23", default-features = false, features = ["ring", "std"] }
tower-http = { version = "0.6", features = ["trace", "fs", "cors"] }
tower-http = { version = "0.6", features = ["trace", "fs", "cors", "set-header"] }

# Webhook signature verification
hmac = "0.12"
Expand Down
8 changes: 8 additions & 0 deletions src/daemon_v2/web/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ pub mod websocket;
mod upload_tests;

use axum::Router;
use axum::http::header;
use axum::routing::{get, post};
use std::path::PathBuf;
use std::sync::Arc;
use tokio::sync::{Mutex, broadcast};
use tower_http::set_header::SetResponseHeaderLayer;

use crate::daemon_v2::events::DomainEvent;
use crate::daemon_v2::projections::Projections;
Expand Down Expand Up @@ -81,5 +83,11 @@ pub fn create_router(state: Arc<WebState>) -> Router {
.route("/api/push/unsubscribe", post(routes::push_unsubscribe))
.route("/webhook", post(routes::webhook_handler))
.route("/api/ws", get(websocket::ws_handler))
// Prevent mobile Safari (PWA) from caching API responses. Without
// this, returning from background can show stale channel history.
.layer(SetResponseHeaderLayer::overriding(
header::CACHE_CONTROL,
header::HeaderValue::from_static("no-store"),
))
.with_state(state)
}
4 changes: 2 additions & 2 deletions web-app/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ export async function fetchHistory(channelName: string | null = null): Promise<v
const url = channelName
? `${getApiBase()}/channels/history?channel=${encodeURIComponent(channelName)}`
: `${getApiBase()}/channels/history`;
const res = await fetch(url, { signal: controller.signal });
const res = await fetch(url, { signal: controller.signal, cache: "no-store" as RequestCache });
if (res.ok) {
const data = await res.json();

Expand Down Expand Up @@ -1667,7 +1667,7 @@ export async function fetchChannelAgentsMd(
try {
let url = `${getApiBase()}/channels/${encodeURIComponent(channel)}/agents-md`;
if (scope) url += `?scope=${encodeURIComponent(scope)}`;
const res = await fetch(url, { signal: controller.signal });
const res = await fetch(url, { signal: controller.signal, cache: "no-store" as RequestCache });
if (res.ok) {
const data = await res.json();
return { ...data, error: null };
Expand Down
Loading