caddyserver / replace-response

Caddy module that performs replacements in response bodies
Apache License 2.0
98 stars 27 forks source link

Environment Variables - Incorrect Replacements #17

Open ManOki opened 1 year ago

ManOki commented 1 year ago

Hi,

I use caddy 2.6.2 with replace-response and noticed some weird replacements. I want to add a webroot/subdirectory to absolute paths which are stored in environment variables DOMAIN=mydomain.com and WEBROOT=/app.

replace https://{$DOMAIN} https://{$DOMAIN}{$WEBROOT} updated response from https://mydomain.com/script.js to https:///appmydomain.com/script.js (incorrect order within environment variable values).

After that I tried replace https://{$DOMAIN} https://before{$DOMAIN}after which results in https://beforeaftermydomain.com/script.js (environment variable values are always suffixed).

I expected https://mydomain.com/app/script.js. The hardcoded workaround replace https://mydomain.com https://mydomain.com/app works as expected.

Greets, ManOki

mholt commented 1 year ago

That's odd. What is the output of caddy adapt on your config?