Skip to content

Commit ee24dab

Browse files
fix: Add user-agent to newm-admin requests
1 parent ea381ca commit ee24dab

8 files changed

Lines changed: 39 additions & 10 deletions

File tree

.github/workflows/newm-admin.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,16 +213,16 @@ jobs:
213213
VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)
214214
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
215215
216-
- name: Initialize and Build MSI
216+
- name: Build MSI
217+
shell: pwsh
217218
run: |
218-
cargo wix init --force
219-
cargo wix --nocapture --target x86_64-pc-windows-msvc
219+
./packaging/windows/build-msi.ps1 -Version "${{ steps.version.outputs.VERSION }}" -Target "x86_64-pc-windows-msvc"
220220
221221
- name: Upload MSI
222222
uses: actions/upload-artifact@v4
223223
with:
224224
name: NEWM-Admin-${{ steps.version.outputs.VERSION }}-windows.msi
225-
path: newm-admin/target/wix/*.msi
225+
path: newm-admin/target/x86_64-pc-windows-msvc/release/NEWM-Admin-${{ steps.version.outputs.VERSION }}-windows.msi
226226

227227
# Release job uploads all packaged artifacts to GitHub Releases
228228
release:

newm-admin/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

newm-admin/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
[package]
22
name = "newm-admin"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
edition = "2024"
5+
authors = ["Andrew Westberg <awestberg@newm.io>"]
6+
license = "Apache-2.0"
7+
license-file = "../LICENSE"
58

69
[dependencies]
710
# GUI Framework

newm-admin/src/auth.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//! Uses async reqwest with async-compat for Tokio compatibility
77
//! within GPUI's async executor.
88
9+
use crate::http_client;
910
use reqwest::Client;
1011
use serde::{Deserialize, Serialize};
1112
use std::fmt;
@@ -133,7 +134,7 @@ impl AuthClient {
133134
/// Create a new authentication client
134135
pub fn new() -> Self {
135136
Self {
136-
client: Client::new(),
137+
client: http_client::new_client(),
137138
}
138139
}
139140

newm-admin/src/earnings.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use async_compat::Compat;
66
use reqwest::Client;
77
use serde::{Deserialize, Serialize};
88

9+
use crate::http_client;
910
use crate::session::{Session, SessionError};
1011

1112
/// Request to add royalties to a song
@@ -81,7 +82,7 @@ impl EarningsClient {
8182
/// Create a new earnings client
8283
pub fn new() -> Self {
8384
Self {
84-
client: Client::new(),
85+
client: http_client::new_client(),
8586
}
8687
}
8788

newm-admin/src/http_client.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//! Shared HTTP client configuration for NEWM Admin.
2+
//!
3+
//! Studio traffic is fronted by an AWS load balancer that rejects requests without a non-empty
4+
//! `User-Agent` header (returns an HTML 403). To keep behavior consistent across environments,
5+
//! we configure a default `User-Agent` for all outbound reqwest requests.
6+
7+
use reqwest::{Client, header};
8+
9+
const USER_AGENT: &str = concat!("newm-admin/", env!("CARGO_PKG_VERSION"));
10+
11+
pub fn new_client() -> Client {
12+
Client::builder()
13+
.default_headers({
14+
let mut headers = header::HeaderMap::new();
15+
headers.insert(
16+
header::USER_AGENT,
17+
header::HeaderValue::from_static(USER_AGENT),
18+
);
19+
headers
20+
})
21+
.build()
22+
.expect("Failed to build reqwest client")
23+
}

newm-admin/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ mod auth;
33
mod colors;
44
mod csv_import;
55
mod earnings;
6+
mod http_client;
67
mod jwt;
78
mod session;
89
mod toast;

newm-admin/src/session.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
66
use async_compat::Compat;
77
use gpui::*;
8-
use reqwest::Client;
98
use std::sync::{Arc, Mutex};
109

1110
use crate::auth::{Environment, LoginResponse};
11+
use crate::http_client;
1212
use crate::jwt;
1313

1414
/// Session state containing authentication tokens
@@ -82,7 +82,7 @@ impl Session {
8282
tracing::info!("Access token expires soon, refreshing...");
8383

8484
// Need to refresh - use the refresh token
85-
let client = Client::new();
85+
let client = http_client::new_client();
8686
let url = self.environment.refresh_url();
8787

8888
let response = Compat::new(async {

0 commit comments

Comments
 (0)