Skip to content

Commit 8b035f4

Browse files
docs: pages and server functions deploy as one unit; split only behind one origin
SSR calls server functions in-process with the request event, so the server bundle is one deployment. A client-only build can put pages and the function endpoint on different hosts, routed under one origin, because server-function calls are same-origin by contract. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 1080b50 commit 8b035f4

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/routes/(3)building-apps/(7)deployment.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ With `start` and `ssr: true`, one build produces:
3030
- `dist/server/server.js`, containing the server entry and its exported request handler.
3131

3232
When server functions are enabled, the server bundle also dispatches their endpoint, `/_server` by default.
33+
Pages and server functions are one deployment: a render calls a server function directly, in the same process, with the request event and its `locals` in hand, so the server bundle cannot be split with pages on one host and functions on another.
3334

3435
Without `ssr: true`, start mode writes the empty document shell to `dist/client/index.html` and removes `dist/server` when the application has no server functions.
3536
If server functions are enabled, deploy `dist/client` for pages and keep `dist/server` running for the function endpoint.
37+
The two can live on different hosts as long as the browser sees one origin: the server-function client calls are same-origin by contract, so route `/_server/*` to the function host from the CDN or proxy that serves the pages rather than pointing the client at another origin.
3638

3739
## The request handler
3840

0 commit comments

Comments
 (0)