fix: keep NEXT_PUBLIC_AUTH_ENABLED out of the minifier constant-fold#549
Merged
Conversation
20 tasks
IliaAvdeev
force-pushed
the
fix/auth-enabled-build-flag
branch
from
June 8, 2026 17:10
92b45ea to
25c6a83
Compare
Author
|
Added tests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
With auth enabled, none of the auth UI shows up in the Docker image — no Admin
link, no Sign out, and the 401 → /login redirect never fires — even though the
backend auth works fine.
The problem is how the build-time flag is read. Both
lib/auth.tsandlib/api.tsdo:In the Docker build the value is injected as the literal
__NEXT_PUBLIC_AUTH_ENABLED_PLACEHOLDER__, andstart-frontend.shrewrites iton container start. But since this is a
"<literal>" === "true"comparison, theminifier folds it down to
falseat build time and drops the placeholdercompletely. By the time the startup script runs there's nothing left to
substitute, so the client flag is stuck at
false.NEXT_PUBLIC_API_BASEavoids this because it's used as a plain string and nevercompared against a literal, so its placeholder survives minification.
The fix reads the raw value and evaluates it at runtime, which keeps the
placeholder in the bundle:
After this,
start-frontend.shcan substitute the placeholder as intended andthe auth UI appears when auth is on.
How to reproduce on
dev: build the image, enable auth (auth.jsonenabled: trueorAUTH_ENABLED=true), start the container, and grep the builtbundle —
AUTH_ENABLEDis baked asfalseand the placeholder is gone. Withthis change the placeholder is preserved and rewritten to
trueat startup.Notes:
pre-commit run --all-files; my changes pass. Two unrelated failuresalready exist on
devand are left untouched as out of scope: a duplicate keyin
web/locales/{en,zh}/app.json(check-json), and Unix-onlyos.getpgid/killpginruntime/launcher.pythat mypy flags on Windows.web/tests/auth-enabled.test.ts, node:test) for the flagparsing — accepted truthy values, falsy/empty/undefined, and that an
unsubstituted Docker placeholder reads as disabled. After extracting the
shared
parseAuthEnabledhelper, the placeholder still survives minification(verified with a production build), so the runtime rewrite is unaffected.
Module(s) Affected
agentsapiconfigcoreknowledgeloggingservicestoolsutilsweb(Frontend)docs(Documentation)scriptstests...Checklist
pre-commit run --all-filesand fixed any issues.