When the "output" in nextConfig is set to "export", an error occurs in the app/api folder during the build process on the 13th.
In my project, I require different build types based on environment variables.
Is there a way to exclude the "api" folder from the build when the "output" is set to "export"?
Upon running the build with nextConfig.output as "export", the following error is encountered:
Export encountered errors on the following paths: /api/revalidate/route: /api/revalidate
src/app/api/revalidate/route.ts file
import { NextRequest, NextResponse } from 'next/server';
import { revalidateTag } from 'next/cache';
export async function GET(request: NextRequest) {
const tag = request.nextUrl.searchParams.get('tag');
if(tag){
revalidateTag(tag);
}
return NextResponse.json({ revalidated: true, now: Date.now() });
}
Next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
output: process.env.NEXT_OUTPUT_MODE,
};
module.exports = nextConfig;
Reproducible repository
Here is a repository link to reproduce this issue https://github.com/zeckaissue/next-export-api-crash