Repository navigation
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 optionalpublic_url, either through--public-urlonpitchfork proxy addor in the config:# PUBLIC_URL is your tunnel's https origin pitchfork proxy add shop --daemon web --public-url "$PUBLIC_URL"
This saves
public_urlon the slug's entry in[slugs], next todiranddaemon. Requests for the slug's own hostname reach the daemon withHost,X-Forwarded-Host,X-Forwarded-ProtoandX-Forwarded-Portset from that URL.- These values come only from your config. The proxy still discards any
X-Forwarded-*headers sent by the client. public_urlmust be anhttporhttpsorigin with no path, query or credentials.proxy addrejects 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 addagain without--public-url, the existing public URL is kept. That means one command can move the public address to another checkout. proxy statusand its JSON output show the public URL.
- These values come only from your config. The proxy still discards any
-
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 independswork as before. Anasname 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
urlwhen the proxy doesn't serve it (#1146) by @jdx. Some daemons get no proxy URL: those withproxy = 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 declaredurl. If a declaredurlfails 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 readsdaemons.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$PORTfor the final value. {{ proxy_url }}still holds only the proxy URL. For a daemon that declaresurl, 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.