1import {
2 defineCloudflareConfig,
3 type OpenNextConfig,
4} from "@opennextjs/cloudflare";
5import staticAssetsCache from "@opennextjs/cloudflare/overrides/incremental-cache/static-assets-incremental-cache";
6
7const handlerPaths = ["/api/config"];
8
9export const buildCommand =
10 "npx next build && node -e \"require('node:fs').writeFileSync('../native-build-marker', 'native');\"";
11
12const config: OpenNextConfig = {
13 ...defineCloudflareConfig({ incrementalCache: staticAssetsCache }),
14 appPath: "native-output",
15 buildOutputPath: "native-output",
16 packageJsonPath: "native-output/package.json",
17 buildCommand,
18 dangerous: {
19 headersAndCookiesPriority: (event) =>
20 handlerPaths.some((prefix) => event.rawPath.startsWith(prefix))
21 ? "handler"
22 : "middleware",
23 },
24};
25
26export default config;