Files
id/scripts/patch-not-found.mjs
T
zeekay 9c5d2ccc2f Deploy Next.js login UI to CF Pages with RFC-compliant OAuth
- Add edge runtime to all routes for CF Pages compatibility
- Add not-found.tsx and build script to work around next-on-pages _not-found bug
- Fix shouldProxyToIAM: /login/oauth/* must proxy to IAM, not match /login APP_PATH
- Add auth.hanzo.ai tenant to middleware TENANTS map
- Remove output:'standalone' from next.config.ts (not needed for CF Pages)
- Add signup, account, forgot-password, callback pages
- Add social-callback and bridge API routes
- Add client resolver and IAM helper libraries
- Configure wrangler.toml for CF Pages deployment

Custom domains active: hanzo.id, auth.hanzo.ai, lux.id, pars.id,
iam.lux.network, id.lux.network, id.zoo.network (zoo.id pending)
2026-03-05 22:49:47 -08:00

32 lines
1.1 KiB
JavaScript

/**
* Workaround for @cloudflare/next-on-pages + Next.js 15
*
* Next.js 15 generates /_not-found as a Node.js function even when
* the root layout exports `runtime = 'edge'`. This script removes
* the _not-found function and its route from the Vercel build output
* so next-on-pages can proceed. The middleware handles 404s anyway.
*/
import { rmSync, readFileSync, writeFileSync } from 'fs'
import { join } from 'path'
const outDir = join(process.cwd(), '.vercel', 'output')
const funcDir = join(outDir, 'functions')
// Remove _not-found function directories
for (const name of ['_not-found.func', '_not-found.rsc.func']) {
try {
rmSync(join(funcDir, name), { recursive: true, force: true })
console.log(`Removed ${name}`)
} catch {}
}
// Remove _not-found route from config.json
const configPath = join(outDir, 'config.json')
const config = JSON.parse(readFileSync(configPath, 'utf8'))
config.routes = (config.routes || []).filter(
(r) => !String(r.dest || '').includes('/_not-found')
)
writeFileSync(configPath, JSON.stringify(config, null, 2))
console.log('Patched config.json — removed _not-found routes')