ion
ion copied to clipboard
Next on cloudflare
This PR add partial support for Next on cloudflare. For now only the middleware and the assets can be deployed on cloudflare, the rest needs to be on aws.
It requires this https://github.com/sst/open-next/pull/449 to be merged to work perfectly ( Likely in 3.0.6 )
The assets are deployed on KV and all the cache related stuff are still in aws.
One big issues i've found while testing was that it seems impossible to invalidate cache when using only worker url. To fix this the cache is disabled by default when no domains is set.
Below is an open-next.config.ts
file that works (and is necessary) to deploy :
import type {OpenNextConfig} from 'open-next/types/open-next.js'
const config = {
default: {
override: {
// This is not necessary, but useful to test streaming
wrapper: 'aws-lambda-streaming',
}
},
middleware: {
external: true,
override: {
wrapper: 'cloudflare',
converter: 'edge'
}
},
imageOptimization: {
// @ts-ignore
loader: 'host',
arch: 'x64'
},
// buildCommand: 'echo "Skipping build..."'
} satisfies OpenNextConfig
export default config