redirectRegex path doesn't work properly

Hi,

I'm trying to redirect incoming requests from /apidocs to /apidocs/ but apparently it's not working.
Without redirection, all links and styles are broken in served files.
This is my dynamic configuration:

[http.middlewares.apidocs-slash.redirectRegex]
regex = "^/apidocs$"
replacement = "/apidocs/"
permanent = true

[http.routers.apidocs]
entryPoints = ["websecure"]
rule= "Host(`kiwi.nadiyar.com`) && PathPrefix(`/apidocs`)"
service = "apidocs"
middlewares = ["apidocs-slash"]
[http.routers.apidocs.tls]
certResolver="mainc"
[[http.services.apidocs.loadBalancer.servers]]
url = "http://caddy:8921"

Any idea what's the problem or how to debug this?

thanks in advance <3

You try to match the path at beginning of the string, but the string is the full URL, see doc.

1 Like

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