Skip to content

Feature/media proxy pass#531

Open
daviddarke wants to merge 3 commits into
mainfrom
feature/media-proxy-pass
Open

Feature/media proxy pass#531
daviddarke wants to merge 3 commits into
mainfrom
feature/media-proxy-pass

Conversation

@daviddarke
Copy link
Copy Markdown
Member

Media Proxy command added. The ability to pass through the HTTP auth that's enabled by default on our staging sites is essential. Obviously, those creds need to be accessible, so the standard .env variables have been updated:

SETUP_INSTALL_AND_BUILD_ONLY=false
WORDPRESS_AUTOMATION_USER="Bot"
WORDPRESS_AUTOMATION_PASSWORD="password"
WORDPRESS_USER=""
WORDPRESS_USER_EMAIL=""
WORDPRESS_PASSWORD=""

STAGING_SSH_USERNAME=""
STAGING_SSH_HOST=""
STAGING_SSH_PORT=""
STAGING_URL="//stg-staging.kinsta.cloud"
STAGING_HTTP_AUTH_USERNAME=""
STAGING_HTTP_AUTH_PASSWORD=""

STAGING_HTTP_AUTH_USERNAME and STAGING_HTTP_AUTH_PASSWORD are new additions.

If these variables aren't preset, no Auth header is added to the proxy.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 8, 2026

🦋 Changeset detected

Latest commit: e94da6a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@atomicsmash/cli Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@daviddarke
Copy link
Copy Markdown
Member Author

daviddarke commented Apr 8, 2026

Also, I wrote most of this, but Claude really helped with the "closing brace" detection logic.

Copy link
Copy Markdown
Member

@mikeybinns mikeybinns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not pulled down for testing yet, but found some minor static code changes

const { projectName } = smashConfig;
const nginxConfigPath = join(
homedir(),
"Library/Application Support/Herd/config/valet/Nginx",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would only work on MacOS, so may not work if we allow windows machines in future, or if a freelancer uses Windows.
Suggest changing to this which supports both (where type is from node:os)

Suggested change
"Library/Application Support/Herd/config/valet/Nginx",
type() === "Darwin" ? "Library/Application Support/Herd/config/valet/Nginx" : ".config\herd\config\nginx",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea

Comment on lines +99 to +100
const httpAuthUsername = process.env.STAGING_HTTP_AUTH_USERNAME;
const httpAuthPassword = process.env.STAGING_HTTP_AUTH_PASSWORD;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Staging auth wont change per dev, so this should be defined in the smash.config.ts instead of the .env

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, but other staging details currently live inside the .env no?

SETUP_INSTALL_AND_BUILD_ONLY=false
WORDPRESS_AUTOMATION_USER="Bot"
WORDPRESS_AUTOMATION_PASSWORD="password"
WORDPRESS_USER=""
WORDPRESS_USER_EMAIL=""
WORDPRESS_PASSWORD=""

STAGING_SSH_USERNAME="site"
STAGING_SSH_HOST="33.333.333.333"
STAGING_SSH_PORT="33333"
STAGING_URL="//site.kinsta.cloud"
MEDIA_DOWNLOAD_MONTHS="-1" # Defaults to -1, which will download all media
MEDIA_DOWNLOAD_PATH="/www/public/current/public/wp-content/uploads"
MEDIA_DOWNLOAD_LOCAL_PATH="./public/wp-content/uploads/" # Where the uploads folder should sit locally

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They do but they shouldn't. There will be a migration to smash config at some point which will involve things being in both places so I think it's better for this new command to use smash config.

Comment on lines +123 to +125
console.log(
"Run `herd restart` or restart Herd via the UI for the changes to take effect.",
);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This must always happen so it's probably best to just run it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok fair.

import { join } from "node:path";
import { getSmashConfig } from "@atomicsmash/smash-config";

export const PROXY_MARKER = "location @uploadsproxy";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable is only used in this file, so it shouldn't be exported.


export const PROXY_MARKER = "location @uploadsproxy";

export function buildProxyBlock(stagingUrl: string, httpAuth?: string) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is only used in this file, so it shouldn't be exported.

}`;
}

export function addProxyBlock(config: string, stagingUrl: string, httpAuth?: string): string {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is only used in this file, so it shouldn't be exported.

);
}

export function removeProxyBlock(config: string): string {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is only used in this file, so it shouldn't be exported.

"@atomicsmash/cli": major
---

Added new toggle media proxy function
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why there's two changesets here, seems to be duplicate

Base automatically changed from pre-release to main May 22, 2026 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants