Route not handling extra path

1. The problem I’m having:

Here’s my Caddyfile:

woofcam.live, www.woofcam.live {
    rewrite /socket.io /socket.io/
    handle_path /socket.io/* {
        rewrite * /socket.io{path}
        reverse_proxy localhost:4005
    }

    handle_path /watcher/* {
        root * /var/www/project/frontend/watcher
        try_files {path} {file} /index.html
        file_server browse
    }
    handle /broadcaster/* {
        root * /var/www/project/frontend/broadcast
        try_files {path} {file} /index.html
        file_server browse
    }
}

I can currently access the /broadcaster route but only if I write https://woofcam.live/broadcaster/anything-else
When I try to access https://woofcam.live/broadcaster without the /anything-else path, it gives back a status 200 but no body. Just blank, no files either.

What I’d like to do is have this site accessible using https://woofcam.live/broadcaster with no extra path.

For the “watcher” route, I’d like to be able to handle something like https://woofcam.live/watcher but also handle https://woofcam.live/watcher/code where /code is a UUID that the website will use. The above Caddyfile works with handling the /code route for the watcher but not without it.

When I rewrite the caddyfile so it’s handle /broadcaster { without the /* as before, the html file loads but the styles and .js files don’t load.

3. Caddy version:

V 2.6.2

4. How I installed and ran Caddy:

The standard way for Debian, Ubuntu etc.

Instead of having the wildcard after the / for the directory, do it for the same folder. If you change your Caddyfile’s handle for watcher to this, it should be corrected:

    handle_path /watcher* {
        root * /var/www/project/frontend/watcher
        try_files {path} {file} /index.html
        file_server browse
    }

It’s the same here, essentially. Change the spot for wildcard and remove the /:

    handle /broadcaster* {
        root * /var/www/project/frontend/broadcast
        try_files {path} {file} /index.html
        file_server browse
    }
1 Like

The wildcard is set after the slash, thus the slash must exist and the rest is filled by the wildcard.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.