Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(local): presign local files for this machine's name in static stacks (#8887)

Wolf Mermelsteine8389b96e973
diff --git a/docs/development/running-locally.md b/docs/development/running-locally.md
index e42de71952..52420053c8 100644
--- a/docs/development/running-locally.md
+++ b/docs/development/running-locally.md
@@ -154,7 +154,8 @@ compiled worker; rebuild the sync image after backend protocol changes.
Open the frontend URL in your browser.
The local environment supplies both `LOCAL_AWS_URL` (the container endpoint)
-and `LOCAL_AWS_PUBLIC_URL` (the app's HTTPS origin with `/local-storage`).
+and `LOCAL_AWS_PUBLIC_URL` (this machine's hostname on the proxy port, with
+`/local-storage`, in both the hot and the static-frontend flavor).
Document downloads and presigned uploads use this storage proxy, so remote
browsers do not need a separate localhost storage connection. Container clients
translate that public endpoint back to LocalStack internally. If a download or
diff --git a/tooling/xtask/crates/xtask_local/src/local/local_env.rs b/tooling/xtask/crates/xtask_local/src/local/local_env.rs
index 326b230a7d..e093735d43 100644
--- a/tooling/xtask/crates/xtask_local/src/local/local_env.rs
+++ b/tooling/xtask/crates/xtask_local/src/local/local_env.rs
@@ -97,7 +97,10 @@ impl LocalEnv {
} else {
frontend::https_origin(instance)?
};
- let infra = InfraEnv::local(&frontend_origin);
+ // Presigned file URLs are opened by a browser that may be on another
+ // machine (a laptop on the tailnet), so they use this machine's name,
+ // which the proxy certificate covers in both flavors, not localhost.
+ let infra = InfraEnv::local(&frontend::https_origin(instance)?);
Ok(LocalEnv {
// Both local flavors run against local infra (`local` env defaults).
environment: mode.environment_var(),
@@ -226,13 +229,13 @@ struct InfraEnv {
}
impl InfraEnv {
- fn local(frontend_origin: &str) -> Self {
+ fn local(browser_origin: &str) -> Self {
InfraEnv {
database_url: "postgres://user:password@postgres:5432/macrodb".into(),
redis_uri: "redis://redis:6379".into(),
opensearch_url: "http://search:9200".into(),
local_aws_url: "http://localstack:4566".into(),
- local_aws_public_url: format!("{frontend_origin}/local-storage"),
+ local_aws_public_url: format!("{browser_origin}/local-storage"),
// The broker's in-network listener (see docker/docker-compose-databases.yml);
// host processes use localhost:9092 instead.
kafka_brokers: "kafka:29092".into(),
diff --git a/tooling/xtask/crates/xtask_local/src/local/local_env/test.rs b/tooling/xtask/crates/xtask_local/src/local/local_env/test.rs
index 36f2c4b968..42e225822e 100644
--- a/tooling/xtask/crates/xtask_local/src/local/local_env/test.rs
+++ b/tooling/xtask/crates/xtask_local/src/local/local_env/test.rs
@@ -667,3 +667,19 @@ fn the_preview_ssh_proxy_host_is_empty_without_a_published_tunnel() {
// The on-machine endpoint stays first; the tunnel is a fallback, not a swap.
assert_eq!(env["PREVIEW_SSH_HOST"], "localhost");
}
+
+#[test]
+fn a_static_stack_presigns_files_for_this_machines_name() {
+ let instance = Instance::derive(Some("image"), None).expect("named instance derives");
+ let env = LocalEnv::for_instance(Mode::Local, &instance, true, Tunnels::default())
+ .unwrap()
+ .to_env();
+ assert_eq!(env["FRONTEND_ORIGIN"], proxy::url(&instance));
+ assert_eq!(
+ env["LOCAL_AWS_PUBLIC_URL"],
+ format!(
+ "{}/local-storage",
+ super::super::frontend::https_origin(&instance).unwrap()
+ )
+ );
+}