Site base URL prefixed with "http://" if set to an environment variable not currently in .env
Open
Nobody has claimed this yet.
bug
severity:minor
- Dominant language
- PHP
- Stars
- 3.6k
- Forks
- 705
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 134
Description
Description
If a site's "Base URL" setting is set to an environment variable (i.e. any value starting with a $) that doesn't actually have a corresponding key in .env, upon saving the site Craft prefixes the value with "http://", which feels like a bug.

Steps to reproduce
- Set the "Base URL" setting to a non-existent environment variable (e.g.
$FOOBAR) - Save the site
- Confirm that Craft has prefixed the environment variable with "http://"
Additional info
- Craft version: 3.5.0-RC6
- PHP version:
- Database driver & version:
- Plugins & versions:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue using the listed Base URL setting and the nonexistent $FOOBAR environment variable, then inspect the code path that saves and normalizes the site URL. Done means saving the setting preserves $FOOBAR without adding http://, with a regression test covering the missing environment variable case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100