Skip to content

v2.36.0: Public URLs for proxy slugs, named dependencies and declared daemon URLs

Latest

Choose a tag to compare

@jdx jdx released this 21 Nov 01:59
· 34 commits to main since this release
Immutable release. Only release title and notes can be modified.
e4467f2

Proxy slugs can now forward requests under a public URL, which helps apps reached through a tunnel. Two config additions make templates easier to write: a dependency can have a local name, and a daemon the proxy doesn't serve can declare its own url.

Added

  • Forward a proxy slug under its public URL (#1141) by @jdx, originally proposed and implemented by @andersonkrs. An app reached through a tunnel (for example cloudflared with httpHostHeader = "shop.localhost") used to see only the local slug name over plain HTTP. That broke redirects, absolute links and CSRF origin checks. A slug can now have an optional public_url, either through --public-url on pitchfork proxy add or in the config:

    # PUBLIC_URL is your tunnel's https origin
    pitchfork proxy add shop --daemon web --public-url "$PUBLIC_URL"

    This saves public_url on the slug's entry in [slugs], next to dir and daemon. Requests for the slug's own hostname reach the daemon with Host, X-Forwarded-Host, X-Forwarded-Proto and X-Forwarded-Port set from that URL.

    • These values come only from your config. The proxy still discards any X-Forwarded-* headers sent by the client.
    • public_url must be an http or https origin with no path, query or credentials. proxy add rejects an invalid value. If an invalid value is already in the config, pitchfork logs a warning and forwards the slug under its local name.
    • Worktree subdomains (<branch>.shop.<tld>) and automatic hostnames keep their local values.
    • If you run proxy add again without --public-url, the existing public URL is kept. That means one command can move the public address to another checkout.
    • proxy status and its JSON output show the public URL.
  • Give a dependency a local name with as (#1144) by @jdx. Templates no longer have to spell out a generated or checkout-specific namespace, such as the namespaces mise creates for each checkout:

    [daemons.app]
    run = "node server.js"
    depends = [{ id = "search-bd9126f3bbca47d/app", as = "search" }]
    
    [daemons.app.env]
    SEARCH_API_URL = "{{ daemons.search.url }}"

    The qualified key (daemons["search-bd9126f3bbca47d.app"]) still works, and plain strings in depends work as before. An as name may use letters, digits, _ and -. Config loading fails if the name is empty or invalid, matches a daemon in the same namespace, or points to two different dependencies. CLI and TUI saves that would cause such a clash are blocked.

  • Declare a daemon url when the proxy doesn't serve it (#1146) by @jdx. Some daemons get no proxy URL: those with proxy = false, those running while the proxy is off, and non-HTTP services such as Redis. These daemons can now declare the URL they answer on as a template:

    [daemons.cache]
    run = "redis-server --port $PORT"
    port = 6380
    proxy = false
    url = "redis://127.0.0.1:{{ port }}/0"
    
    [daemons.web]
    depends = ["cache"]
    run = "./web"
    env.REDIS_URL = "{{ daemons.cache.url }}"
    • {{ url }} and {{ daemons.<name>.url }} use the proxy URL when the proxy serves the daemon. Otherwise they use the declared url. If a declared url fails to render, pitchfork logs it and treats the value as null.
    • New self variables {{ port }} and {{ ports }} hold the daemon's configured ports. When another daemon reads daemons.cache.url, {{ port }} is the port the daemon actually got, including after a bump. Inside the daemon's own config it is the configured port, so use $PORT for the final value.
    • {{ proxy_url }} still holds only the proxy URL. For a daemon that declares url, it is no longer the same as {{ url }}.

Full Changelog: v2.35.0...v2.36.0

💚 Sponsor pitchfork

pitchfork is built and maintained by @jdx, an open source developer at entire.io, the title sponsor of his open source work.

If pitchfork has a place in your development workflow, please consider becoming an individual or company sponsor. Your support funds ongoing development and helps keep pitchfork fast, free, and independent.