fix(web): use dynamic import for react-dom/server in API route
Next.js bundler flags react-dom/server imports even in API routes during static analysis. Using dynamic import (await import()) ensures it only loads at runtime on the server. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
5956217979
commit
4f93c7d996
|
|
@ -3,7 +3,6 @@ import { writeFileSync, readFileSync, mkdirSync, rmSync } from 'fs'
|
|||
import { tmpdir } from 'os'
|
||||
import { join } from 'path'
|
||||
import { execSync } from 'child_process'
|
||||
import { renderToStaticMarkup } from 'react-dom/server'
|
||||
import { generateMonthlyTypst, generateDailyTypst, getDaysInMonth } from '../utils/typstGenerator'
|
||||
import type { AbacusConfig } from '@soroban/abacus-react'
|
||||
import { generateCalendarComposite } from '@/../../scripts/generateCalendarComposite'
|
||||
|
|
@ -21,6 +20,9 @@ export async function POST(request: NextRequest) {
|
|||
let tempDir: string | null = null
|
||||
|
||||
try {
|
||||
// Dynamic import to avoid Next.js bundler issues with react-dom/server
|
||||
const { renderToStaticMarkup } = await import('react-dom/server')
|
||||
|
||||
const body: CalendarRequest = await request.json()
|
||||
const { month, year, format, paperSize, abacusConfig } = body
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue