Caddy not replacing env variables templates

1. Caddy version (caddy version):


2. How I run Caddy:

/usr/bin/caddy run --config /opt/app-root/etc/Caddyfile

a. System environment:


b. My Config

    # Where caddy should listen

    # Turn on the Web/file server

    # The site root
    root * /opt/app-root/src

    # Because we should
    encode zstd gzip

    # This rewrite rule may be required to get React apps
    # to deal with trailing slashes properly.
    #@filter {
    #	not path_regexp ^\/
    #	file {
    #		try_files {path} {path}/ /?url={uri}
    #	}
    #rewrite @try_files {http.matchers.file.relative}

    # On OCP we should log to stdout so Prometheus can
    # slurp up the logs for human consumption.
    log {
      #errors stdout
      output stdout 
      format single_field common_log
      level info

3. The problem Iā€™m having:

Caddy does not seem to be replacing the template {{env "MY_ENV_VAR"}} in .js files. Use to work fine with the old Caddy v1 with {{.env.MY_ENV_VAR}}.

By default, templates only runs on files with MIME types text/html and text/plain. You can configure this to add text/javascript as well:

1 Like

Thanks. That was it.

1 Like

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