From 47890e05623d448e9a2d8c84eec4b80f1f066ffe Mon Sep 17 00:00:00 2001 From: Tee Ming Date: Thu, 12 Dec 2024 22:19:58 +0800 Subject: [PATCH] docs: explain that +layout files do not affect +server.js (#13152) closes #12401 --- documentation/docs/20-core-concepts/10-routing.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/documentation/docs/20-core-concepts/10-routing.md b/documentation/docs/20-core-concepts/10-routing.md index b54074cdd75a..c33229f851e9 100644 --- a/documentation/docs/20-core-concepts/10-routing.md +++ b/documentation/docs/20-core-concepts/10-routing.md @@ -53,7 +53,7 @@ Pages can receive data from `load` functions via the `data` prop. > [!LEGACY] > In Svelte 4, you'd use `export let data` instead -> [!NOTE] Note that SvelteKit uses `` elements to navigate between routes, rather than a framework-specific `` component. +> [!NOTE] SvelteKit uses `` elements to navigate between routes, rather than a framework-specific `` component. ### +page.js @@ -302,6 +302,8 @@ If an error is thrown (either `error(...)` or an unexpected error), the response > [!NOTE] When creating an `OPTIONS` handler, note that Vite will inject `Access-Control-Allow-Origin` and `Access-Control-Allow-Methods` headers — these will not be present in production unless you add them. +> [!NOTE] `+layout` files have no effect on `+server.js` files. If you want to run some logic before each request, add it to the server [`handle`](hooks#Server-hooks-handle) hook. + ### Receiving data By exporting `POST`/`PUT`/`PATCH`/`DELETE`/`OPTIONS`/`HEAD` handlers, `+server.js` files can be used to create a complete API: