craftcms / craftcms/cms

Site base URL prefixed with "http://" if set to an environment variable not currently in .env

Open
#6,528 1 comment 0 reactions 0 assignees View on GitHub

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.

image

Steps to reproduce
  1. Set the "Base URL" setting to a non-existent environment variable (e.g. $FOOBAR)
  2. Save the site
  3. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.