Next.js Discord

Discord Forum

How to make build skip certain routes?

Unanswered
American posted this in #help-forum
Open in Discord
Avatar
AmericanOP
During build in my CI pipeline, NextJS tries to build a path and fails:

Error: Failed to collect page data for /labs/spellcheck/api

This is a route.ts file which needs some env var that isn't available during build time. How can I tell NextJS to skip it? I tried using export const dynamic = "force-dynamic"; but no change

1 Reply

Avatar
AmericanOP
Had to rework the logic a bit, instead of doing import {openai} I did import {getOpenAI} and later const openai = await getOpenAI()