bastienwirtz / homer

A very simple static homepage for your server.
https://homer-demo.netlify.app/
Apache License 2.0
9.19k stars 781 forks source link

How to fix ping CORS issue with Docker? #775

Closed Tama47 closed 2 months ago

Tama47 commented 4 months ago

Referring to this: https://github.com/bastienwirtz/homer/blob/main/docs/troubleshooting.md#my-custom-service-card-doesnt-work-nothing-appears-or-offline-status-is-displayed-pi-hole-sonarr-ping-

Modify the target server configuration so that the response of the server included following header- Access-Control-Allow-Origin: * (https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#simple_requests). It might be an option in the targeted service, otherwise depending on how the service is hosted, the proxy or web server can seamlessly add it.

Use a cors proxy server like cors-container, cors-anywhere or many others.

Specifically would like to do option 2 or 3, as option 1 isn't feasible.

docker-compose:

version: "2"
services:
  homer:
    image: b4bz/homer
    container_name: Homer
    volumes:
      - ./assets:/www/assets
    environment:
      - INIT_ASSETS=1

config.yaml:

- name: "Pi-hole - Synology"
        logo: "assets/tools/Pi-hole.svg"
        subtitle: "192.168.1.10:8080"
        url: "http://pi.hole:80"
        target: "_blank"
        tag: "Tools"
        type: Ping
fanuch commented 4 months ago

https://github.com/pi-hole/docker-pi-hole?tab=readme-ov-file#advanced-variables Look at value CORS_HOSTS

I believe that would solve for "option 2"

bastienwirtz commented 2 months ago

Hello, As said by @fanuch, CORS_HOSTS should do the work. You can have a look at this https://github.com/bastienwirtz/homer/issues/478, lots of information here. I think the subject is well known and documented, I'm closing the issue but feel free to reopen it if necessary.