Skip to content

Allow audiusAppUrl to be overridden via env var - #747

Merged
rickyrombo merged 1 commit into
mainfrom
mjp-audiusappurl-env
Aug 5, 2026
Merged

Allow audiusAppUrl to be overridden via env var#747
rickyrombo merged 1 commit into
mainfrom
mjp-audiusappurl-env

Conversation

@rickyrombo

@rickyrombo rickyrombo commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Cfg.AudiusAppUrl was hardcoded inside the per-env switch in config.init() for dev, stage and prod, so it could not be pointed at a non-default frontend without a code change. Developer apps running against a local override or preview deploy got the wrong redirect_uri base.

This applies an audiusAppUrl env override after the switch, alongside the existing archiverNodes and antiAbuseOracles overrides that solve the same problem for values the switch also sets per-env:

// Override the Audius app base URL when set, so developer apps running against a
// non-default frontend (local override, preview deploy) get the right redirect_uri base.
if v := os.Getenv("audiusAppUrl"); v != "" {
    Cfg.AudiusAppUrl = strings.TrimSuffix(v, "/")
}

Placing it after the switch means it covers every env and cannot be silently missed when a new env case is added — the earlier revision of this PR guarded dev and prod individually, and a stage default added to main in the meantime went unguarded.

The trailing slash is trimmed because every consumer builds URLs as base + "/..." (v1_oauth.go, v1_sitemaps.go, v1_users_sales_download.go, v1_users_purchases_download.go), so a trailing slash would produce //.

Rebased onto current main — the previous revision was 246 commits behind and conflicting.

Test plan

go build, go vet and gofmt are clean. A standard unit test can't cover this: init() runs at package load, before t.Setenv could take effect. Verified instead by running the real package across the env matrix:

ENV audiusAppUrl Cfg.AudiusAppUrl
dev (unset) http://localhost:3000
dev http://custom.example http://custom.example
stage (unset) https://staging.audius.co
stage http://custom.example http://custom.example
prod (unset) https://audius.co
prod https://preview.audius.co https://preview.audius.co
prod https://trailing.example/ https://trailing.example

Note

Cfg.AudiusdURL has the same latent bug — read from os.Getenv("audiusdUrl") in the Cfg initializer, then unconditionally overwritten in all three switch branches. Left alone as out of scope.

🤖 Generated with Claude Code

The per-env switch in init() hardcoded Cfg.AudiusAppUrl for dev, stage and
prod, so the value could not be pointed at a non-default frontend without a
code change. Developer apps running against a local override or preview
deploy got the wrong redirect_uri base.

Apply the env var after the switch, alongside the existing archiverNodes and
antiAbuseOracles overrides, so it covers every env and cannot be missed when
a new env case is added. Trailing slash is trimmed because all consumers
build URLs as base + "/...".

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@rickyrombo
rickyrombo force-pushed the mjp-audiusappurl-env branch from 85d7fda to 24e301d Compare August 5, 2026 04:29
@rickyrombo
rickyrombo merged commit 65242c9 into main Aug 5, 2026
1 of 2 checks passed
@rickyrombo
rickyrombo deleted the mjp-audiusappurl-env branch August 5, 2026 04:33
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.

1 participant