An error occured: Check your connection and your registry must have `Access-Control-Allow-Origin` header set to `http://localhost:8888`
Hi, I use this docker registry UI and I have an issue...
Bug description
An error occured: Check your connection and your registry must have Access-Control-Allow-Origin header set to http://localhost:8888
How to Reproduce
Just compose up the following configuration file and open up a browser in http://localhost:8888/
My docker-compose file
services:
registry:
image: registry:2
restart: always
ports:
- "5000:5000"
volumes:
- ./auth:/auth
- ./data:/var/lib/registry
- ./config.yml:/etc/docker/registry/config.yml
networks:
- registry-net
ui:
image: joxit/docker-registry-ui:latest
restart: always
ports:
- "8888:80" # UI chạy trên cổng 8888
environment:
REGISTRY_URL: "http://registry:5000"
REGISTRY_TITLE: "My Private Registry"
SINGLE_REGISTRY: "true"
DELETE_IMAGES: "true"
networks:
- registry-net
depends_on:
- registry
networks: registry-net:
My config.yml file
version: 0.1
log:
fields:
service: registry
http:
addr: :5000
headers:
X-Content-Type-Options: [nosniff]
Access-Control-Allow-Origin: ['*']
Access-Control-Allow-Methods: ['HEAD', 'GET', 'OPTIONS', 'DELETE']
Access-Control-Allow-Headers: ['Authorization', 'Accept']
Access-Control-Max-Age: [1728000]
Access-Control-Allow-Credentials: [true]
Access-Control-Expose-Headers: ['Docker-Content-Digest']
storage:
filesystem:
rootdirectory: /var/lib/registry
delete:
enabled: true
cache:
blobdescriptor: inmemory
auth:
htpasswd:
realm: "Registry Realm"
path: /auth/htpasswd
System information
- OS: Windows Server 2019
- Browser:
- Name: MS Edge
- Version: 132.0.2957.140
- Docker registry UI:
- Version: laster
- Server: docker
- Docker version: 27.4.0
- Docker registry ui tag: lastest
- Tools: docker-compose
I think you need to explicitly specify the registry URL/IP in Access-Control-Allow-Origin, because I think how it works is that the browser checks the literal string against the actual origin (http://registry:5000 or whatever you have set up). So a wildcard would not work
Hi there, @ugr3y is write, when using registry with basic auth or any secured endpoint, the wildcard on Access-Control-Allow-Origin will not work.
Everyting is in the Using CORS section