Repository navigation
Improves the proxy: status HTTP, timeouts, cache, fallback stale and URL resolver - #32
Merged
Merged
Conversation
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…the rule The cache flag and the methods list were reset on every segment of a proxy rule, so `cache` and `methods(...)` only took effect as the last segment. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Responses from the proxied host were always returned as 200. The status is now forwarded as is and failed responses are no longer written to the cache. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… failure Requests to the proxied host now use FRONTIER_PROXY_TIMEOUT (5s) and FRONTIER_PROXY_CONNECT_TIMEOUT (2s). A connection failure returns 504 instead of raising an exception. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The file based cache was per server, keyed only by the host and never expired. Cached GET responses now live in the configured cache store, keyed by the final URL, with a TTL (FRONTIER_PROXY_CACHE_TTL, 60s) and an X-Frontier-Cache header reporting hit or miss. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Successful cached responses are also kept as a stale copy for FRONTIER_PROXY_CACHE_STALE_TTL (24h). When the host answers a 5xx or cannot be reached, the stale copy is served with X-Frontier-Cache: stale. Client errors are still forwarded untouched. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Frontier::resolveUrlUsing() registers a callback that receives the URL, the current request and the rule config, so apps can pin a frontend version per tenant. The cache key uses the resolved URL. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A rule with a prefix such as /new answered /new by fetching host/new/new,
because the default of the optional {uri?} parameter repeated the prefix. The
proxied path now mirrors the requested one, trailing slash included. The
request is injected per invocation instead of the constructor, since the route
reuses the controller instance in long running processes.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
GET and HEAD requests dropped the query string, so an asset requested as /x.js?v=1 reached the host as /x.js. The query is now part of the proxied URL, which also makes the cache key and the URL resolver see it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…he proxy type FRONTIER_DEFAULT_ENABLED and FRONTIER_PROXY_ENABLED were missing from the env var table, and FRONTIER_CACHE had a typo. Also note that status forwarding, timeouts, cache and the URL resolver only apply to the proxy type, not http. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The task plan was a working document for this branch, not reference documentation for the library. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2 tasks done
edineivaldameri
pushed a commit
to edineivaldameri/frontier
that referenced
this pull request
Oct 7, 2026
The proxy improvements merged in edersoares#32 change the behavior of the proxy type and are not released yet. The changelog records them under Unreleased so the next release has its notes ready. FRONTIER_PROXY was documented in the README and covered by a test, but nothing in the package reads it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contexto
Análise do uso do Frontier no i-Educar (UI Nuxt sob
/new, proxy) apontou quatro pontos fracos noFrontendProxyController: sem timeout, status HTTP não repassado, cache em arquivo inutilizável em produção,e nenhuma forma de fixar a versão da UI por tenant. Durante a implementação apareceram mais dois bugs:
parsing de segmentos das regras e caminho duplicado (
host/web/web) para regras com prefixo.Cada mudança é um commit isolado, com teste próprio. Cobertura de testes em 100% do início ao fim.
Mudanças
Correções
cacheemethods(...)de uma regra passam a valer em qualquer posição, não só como último segmento.(
/new) pediahost/new/newem vez dehost/new.GET/HEAD, é repassada ao host e entra na chave de cache.Funcionalidades
404/500do CDN deixa de virar200, e respostas comfalha não são cacheadas.
FRONTIER_PROXY_TIMEOUT,FRONTIER_PROXY_CONNECT_TIMEOUT). Falha de conexão responde504em vez de travar o worker do PHP-FPM.Cachefacade, chaveado pela URL final (host + uri +query), com TTL configurável e header
X-Frontier-Cache: hit|miss.200quando o host responde5xxou não responde,enquanto 4xx continua sendo repassado como está.
Frontier::resolveUrlUsing()permite resolver a URL do proxy em tempo de requisição, por exemplo parafixar a versão da UI por tenant.
Docs
resolver, e nota de que essas melhorias valem só para o tipo
proxy(o tipohttpmantém o cache antigo).FRONTIER_DEFAULT_ENABLED,FRONTIER_PROXY_ENABLED) e um typo antigo na descrição deFRONTIER_CACHE.Breaking change
O cache do proxy não é mais limpo por
php artisan view:clear. Agora éphp artisan cache:clear, ou apontarFRONTIER_PROXY_CACHE_STOREpara um store dedicado que possa ser limpo isoladamente.Validação
composer test(Pest): 42 passed.XDEBUG_MODE=coverage vendor/bin/pest --coverage: 100.0% em todas as classes.composer lint(Pint): sem alterações pendentes.🤖 Generated with Claude Code