| 1 | import { |
| 2 | defineCloudflareConfig, |
| 3 | type OpenNextConfig, |
| 4 | } from "@opennextjs/cloudflare"; |
| 5 | import staticAssetsCache from "@opennextjs/cloudflare/overrides/incremental-cache/static-assets-incremental-cache"; |
| 6 | |
| 7 | const handlerPaths = ["/api/config"]; |
| 8 | |
| 9 | export const buildCommand = |
| 10 | "npx next build && node -e \"require('node:fs').writeFileSync('../native-build-marker', 'native');\""; |
| 11 | |
| 12 | const 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 | |
| 26 | export default config; |