@rsc-kit/mcp 0.37.0 → 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/recipes.js +38 -5
- package/dist/recipes.js.map +1 -1
- package/guides/api-routes.md +24 -0
- package/guides/backend-answered-pages.md +5 -1
- package/guides/deployment.md +4 -1
- package/guides/domains.md +33 -2
- package/guides/edge-caching.md +16 -10
- package/guides/go.md +1 -1
- package/guides/laravel.md +30 -6
- package/guides/typed-routes.md +4 -0
- package/guides/your-own-backend.md +3 -3
- package/package.json +2 -2
package/dist/recipes.js
CHANGED
|
@@ -691,14 +691,18 @@ stale-if-error=86400 and CDN-Cache-Control: max-age=60,
|
|
|
691
691
|
stale-while-revalidate=86400, stale-if-error=86400 with an ETag only if the
|
|
692
692
|
render read nothing of the visitor; a 404 is kept a minute at most. A CDN that
|
|
693
693
|
reads CDN-Cache-Control caches on it (Homeport's edge reads nothing else, and
|
|
694
|
-
strips it, so it is not visible in a browser there).
|
|
694
|
+
strips it, so it is not visible in a browser there). CDN-Cache-Control is sent
|
|
695
|
+
ONLY when a purge can reach the CDN (CDN_PURGE_URL set, or installPurge()), so
|
|
696
|
+
an edge never keeps a page changed() cannot take back; s-maxage still says the
|
|
697
|
+
lifetime. purge({ paths }) also sends a subdomain folder's path as visitors use
|
|
698
|
+
it: /merchant/orders purges /orders too. stale-if-error lets the CDN serve the
|
|
695
699
|
kept copy while the origin is down or deploying. The tags of every
|
|
696
700
|
cache(fn, { tags }) answer it used go out as Cache-Tag: posts,post:1, for a
|
|
697
701
|
CDN that purges by tag. changed(tag) calls the purge installed with
|
|
698
702
|
installPurge(async ({ tags }) => ...) from @rsc-kit/core/purge, after the
|
|
699
703
|
answer has gone - one hook, any CDN's API; a failure is logged, never fails
|
|
700
|
-
the change. With
|
|
701
|
-
|
|
704
|
+
the change. With CDN_PURGE_URL set it is cdnPurge() with nothing to install;
|
|
705
|
+
CDN_PURGE_URL is the ONLY name read (RSC_PURGE_URL and HOMEPORT_PURGE_URL no longer are; homeportPurge() is now cdnPurge(), no alias). Rsc::changed() and reg.Changed() post their own purge
|
|
702
706
|
there, since a backend's change never passes through the engine. The host also keeps the page itself - ISR on every host: a
|
|
703
707
|
repeat request is answered from the kept copy (X-RSC-Kit: cached, Age); past
|
|
704
708
|
revalidate the stale copy goes out at once while one render replaces it;
|
|
@@ -989,6 +993,11 @@ before the handler runs (Sec-Fetch-Site, else Origin against the host - Go's
|
|
|
989
993
|
http.CrossOriginProtection rule; actions and forms too). No CSRF token: do NOT
|
|
990
994
|
add one. A webhook or server sends neither header and is never refused. Another
|
|
991
995
|
origin that should post: rscKit({ trustedOrigins: ['https://admin.example.com'] }).
|
|
996
|
+
An api ANY site posts to from the browser (an embedded widget, its origins in a
|
|
997
|
+
database): export const crossOrigin = true in that route.ts (a literal). Another
|
|
998
|
+
site's request then reaches the handler WITHOUT the visitor's cookies (cookies(),
|
|
999
|
+
headers(), request and backend calls see none) - authenticate with a key the
|
|
1000
|
+
caller sends, check Origin yourself, and export OPTIONS for the CORS preflight.
|
|
992
1001
|
|
|
993
1002
|
They run their directory's \`middleware.ts\`, so an endpoint under a guarded
|
|
994
1003
|
path is guarded.
|
|
@@ -1687,6 +1696,18 @@ kept; with none named a folder's url is its path. Same string on server and
|
|
|
1687
1696
|
browser; works in <Link>, visit() and redirect(). Do NOT build
|
|
1688
1697
|
\`//\${slug}.\${host}\` by hand or read the request host for links.
|
|
1689
1698
|
|
|
1699
|
+
A folder only ever seen on its subdomain: rscKit({ hosts: [...], subdomains:
|
|
1700
|
+
['merchant'] }). Then example.com/merchant/orders is a 301 to
|
|
1701
|
+
merchant.example.com/orders (only on the site's own host - not localhost, a
|
|
1702
|
+
preview or <app>.homeport.run, where the path form renders and links keep it;
|
|
1703
|
+
edge.json leaves the folder out; a backendPaths entry under it stops the
|
|
1704
|
+
build); <Link href="/merchant/orders">,
|
|
1705
|
+
visit() and redirect() go to the subdomain with no hostUrl; on the subdomain
|
|
1706
|
+
href="/pricing" goes to the site; Laravel's route('merchant.orders') is the
|
|
1707
|
+
subdomain url. example.com/merchant is then the subdomain's home - a landing
|
|
1708
|
+
page goes in its own folder (app/sell/). Needs hosts and app/merchant/, or dev
|
|
1709
|
+
and the build stop.
|
|
1710
|
+
|
|
1690
1711
|
\`\`\`tsx
|
|
1691
1712
|
// src/app/[domain]/layout.tsx
|
|
1692
1713
|
export default async function TenantLayout({ params, children }) {
|
|
@@ -1892,8 +1913,16 @@ when the renderer is in front. Name the backend's prefixes, and they are
|
|
|
1892
1913
|
forwarded BEFORE any page is asked: rscKit({ backendPaths: ['/auth', '/github',
|
|
1893
1914
|
'/gitlab'] }). A prefix at a segment boundary (/auth, not /authors), every
|
|
1894
1915
|
method; '/', /_rsc and the host-call endpoint (/__rsc/host-call) are refused; a
|
|
1895
|
-
team called auth is then unreachable.
|
|
1896
|
-
|
|
1916
|
+
team called auth is then unreachable. A whole segment in brackets is any one
|
|
1917
|
+
segment: backendPaths: ['/login/[provider]'] is /login/google and what is under
|
|
1918
|
+
it, NOT /login, which stays the page - for a backend route with a parameter
|
|
1919
|
+
under a url that is a page. A page it would cover (login/forgot/page.tsx) stops
|
|
1920
|
+
dev and the build, since it would never render; a dynamic FIRST segment and a
|
|
1921
|
+
catch-all are refused; nothing is checked per request. Prefer a prefix of the
|
|
1922
|
+
backend's own ('/auth') when the urls can move. The build lists the plain
|
|
1923
|
+
prefixes as backendPaths in
|
|
1924
|
+
.output/rsc-kit.json ([] when none; a dynamic one is left out and goes through
|
|
1925
|
+
the renderer), so a proxy in front sends them straight to
|
|
1897
1926
|
the backend instead of through the renderer. The renderer never forwards a
|
|
1898
1927
|
browser's request for the host-call endpoint: it answers with its not-found page. Do NOT
|
|
1899
1928
|
write catch-all route.ts files that forward by hand: that copies the forwarding.
|
|
@@ -1954,6 +1983,10 @@ Billing/Invoices). Do NOT hand-write the attributes from memory; the command
|
|
|
1954
1983
|
writes the ones the registry reads, and it writes the manifest
|
|
1955
1984
|
(rsc-host.json) too - a running dev server restarts on its own when it
|
|
1956
1985
|
changes, so the export is importable when the command returns.
|
|
1986
|
+
One dev server per app: a second vite names the one already running (composer
|
|
1987
|
+
dev, Herd's artisan dev or an editor may have started it) - use that one. In a
|
|
1988
|
+
terminal the second exits, naming the pid to stop; under a runner it waits and
|
|
1989
|
+
starts when the first stops. A vite that sits waiting is not hung.
|
|
1957
1990
|
Server actions are classes in app/Rsc/Actions, found by reflection in PHP;
|
|
1958
1991
|
\`php artisan rsc:host-manifest\` writes rsc-host.json - { actions,
|
|
1959
1992
|
functions } - and vite.config.ts runs it as dev and every build start:
|