Resolve the examiner link host instead of defaulting to localhost - #1975
Merged
vikrantwiz02 merged 1 commit intoAug 28, 2026
Merged
Conversation
Invitation and review-form links were built from FRONTEND_URL, which is only ever read from the process environment and defaults to the development server. No .env file is loaded anywhere, so a deployment that had not exported the variable mailed links to localhost, and the mails also go out from a background task that does not necessarily inherit the web server's environment. An examiner outside the institute could not open them. An exported FRONTEND_URL still wins. Failing that the domain registered in the sites table is used, which is already the institute host, and if neither is configured the old default is kept and a warning is logged so the misconfiguration is visible rather than silent.
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.
Thesis examiners were being mailed links to
http://localhost:5173, which nobody outside a developer's machine can open.Cause. The links were built from
getattr(settings, 'FRONTEND_URL', 'http://localhost:5173'), and insettings/common.pythat value is read only from the process environment:Nothing in the project loads a
.envfile, so editing a settings file on a deployment cannot change it — only an exported variable can. These mails also go out from the background task intasks.py, which does not necessarily inherit the web server's environment, so even an exported variable is not enough on its own.DEBUGis no guard either, since it is left true in the production settings module.Fix.
frontend_base_url()inacademic_procedures/utils.pyresolves in order: an exportedFRONTEND_URL, then the domain registered in the sites table, then the previous default with a logged warning so the next misconfiguration is visible rather than silent. A bare domain getshttps, unless it is localhost. All four link builders in the file use it — invitation accept and reject, the review form, and the reminder.Verified each branch of the resolver, restoring the site row afterwards:
example.comRendering the real templates produces
/thesis-invitation/<token>/accept,/thesis-invitation/<token>/rejectand/thesis-evaluation/<token>against the institute host, which match the routes the client declares inApp.jsx. Local development is unchanged: exportingFRONTEND_URL=http://localhost:5173takes precedence.Not touched: three link builders in
academic_procedures/admin.pyfall back tohttp://localhost:8000via aSITE_URLsetting that is not defined anywhere. Those are backend URLs built withreverse()and the backend is served on a different port from the client, so they need a separate decision rather than this resolver.