svenstaro / miniserve

🌟 For when you really just want to serve some files over HTTP right now!
MIT License
5.95k stars 289 forks source link

CSS not working when root domain not accessible #1406

Open brandonfl opened 4 months ago

brandonfl commented 4 months ago

Hello,

Description

I am trying to create a miniserve with basicauth by path, for example :

But

Problem

The CSS do not work as it try to get it from "url.com/CSS" but the access to "url.com/" is denied

How to repro

Here how I am doing with traefik :

Spoiler
labels:

    # service
    traefik.enable: "true"
    traefik.http.services.miniserve.loadbalancer.server.port: "8080"

    # test
    traefik.http.routers.miniserve-test.rule: "Host(`url.com`) && PathPrefix(`/test`)"
    traefik.http.routers.miniserve-test.tls: "true"
    traefik.http.routers.miniserve-test.entrypoints: "web-secure"
    traefik.http.routers.miniserve-test.service: "miniserve"
    traefik.http.routers.miniserve-test.middlewares: "miniserve-test-auth, contentCompression@file, autodetectContenttype@file"
    traefik.http.middlewares.miniserve-test-auth.basicauth.removeheader: true
    traefik.http.middlewares.miniserve-test-auth.basicauth.users: "..."

    # toto
    traefik.http.routers.miniserve-toto.rule: "Host(`url.com`) && PathPrefix(`/toto`)"
    traefik.http.routers.miniserve-toto.tls: "true"
    traefik.http.routers.miniserve-toto.entrypoints: "web-secure"
    traefik.http.routers.miniserve-toto.service: "miniserve"
    traefik.http.routers.miniserve-toto.middlewares: "miniserve-toto-auth, contentCompression@file, autodetectContenttype@file"
    traefik.http.middlewares.miniserve-toto-auth.basicauth.removeheader: true
    traefik.http.middlewares.miniserve-toto-auth.basicauth.users: "..."
  

Possible solution

Is there a way to make the css file accessible to all path even if the / is not accessible ? Like having the CSS in relative path ?

Thanks in advance, BrandonFL