Control Panel Doesn't Load Properly on Non-standard Port
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.6k
- Forks
- 705
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 134
Description
Description
The control panel doesn't seem to load resources properly when running craft on non-standard ports. The links all reference the correct port but resources like images, scripts, and stylesheets drop the port number.
It just tries to load resources from localhost even though I configured the BASE_CP_URL to be localhost:5000.
docker-compose.yml
version: '3'
services:
app:
build:
context: .
dockerfile: .docker-config/php/Dockerfile
expose:
- 9000
volumes:
- ./craft:/var/www/html
environment:
COMPOSER_ALLOW_SUPERUSER: 1
ENVIRONMENT: dev
SECURITY_KEY: security_key
DB_DSN: mysql:host=database;port=3306;dbname=craft
DB_USER: user
DB_PASSWORD: password
DEFAULT_SITE_URL: http://localhost:5000
BASE_CP_URL: http://localhost:5000
database:
build:
context: .
dockerfile: .docker-config/mysql/Dockerfile
volumes:
- ./craft/storage/db:/var/lib/mysql
ports:
- 3306:3306
environment:
MYSQL_DATABASE: craft
MYSQL_USER: user
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: password
phpmyadmin:
image: phpmyadmin/phpmyadmin
ports:
- 8085:80
environment:
PMA_HOST: database
nginx:
build:
context: .
dockerfile: .docker-config/nginx/Dockerfile
ports:
- 5000:80
volumes:
- ./craft/web:/var/www/html/web
depends_on:
- app
config/general.php
<?php
return [
'*' => [
// Control Panel access via environment variable
'baseCpUrl' => craft\helpers\App::env('BASE_CP_URL') ?: null,
// Control Panel trigger word
'cpTrigger' => 'admin-login',
],
];
We do not use .env files.
Steps to reproduce
- Use above configuration
- Navigate to control panel
Additional info
- Craft version: 3.7.36
- PHP version: 8.1.3
- Database driver & version: MySQL 8.0+
- Plugins & versions: Will provide upon request
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 with docker-compose.yml and config/general.php, then reproduce the control panel resource requests on port 5000. Trace how BASE_CP_URL is used for images, scripts, and stylesheets, and confirm the fix by verifying that every resource URL retains the configured port.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker-compose, mysql, php
- Domain
- backend, devops, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100