fix(storage): make next/headers import lazy in api.js to avoid module resolution failure

- replace top-level `import { cookies } from 'next/headers'` with lazy `await import('next/headers')` inside handler
- document the constraint in PROJECT.md: no top-level next/headers or next/navigation imports reachable from module register() chains
This commit is contained in:
2026-04-25 13:08:14 -04:00
parent 7d6765b58b
commit 6b3bb6a4ee
2 changed files with 23 additions and 1 deletions
+1 -1
View File
@@ -15,7 +15,6 @@
* registerFeatureRoutes in core/api/runtime.js.
*/
import { cookies } from 'next/headers';
import { getSessionCookieName } from '@zen/core/shared/config';
import { getSessionResolver } from '../api/router.js';
import { getFile } from './index.js';
@@ -60,6 +59,7 @@ async function handleGetFile(_request, { wildcard: fileKey }) {
}
// Require authentication for all other paths.
const { cookies } = await import('next/headers');
const cookieStore = await cookies();
const sessionToken = cookieStore.get(COOKIE_NAME)?.value;