Next.js14.2.28: Unable to find lambda for route: /recommend

[08:54:07.410] Running build in Washington, D.C., USA (East) – iad1
[08:54:07.411] Build machine configuration: 2 cores, 8 GB
[08:54:07.428] Cloning github.com/zhanghanting/giftideas (Branch: master, Commit: 8a3afc0)
[08:54:07.437] Skipping build cache, deployment was triggered without cache.
[08:54:07.847] Cloning completed: 419.000ms
[08:54:08.243] Running “vercel build”
[08:54:08.634] Vercel CLI 41.7.3
[08:54:08.967] Installing dependencies…
[08:54:12.334] npm warn deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
[08:54:15.305] npm warn deprecated glob@7.1.7: Glob versions prior to v9 are no longer supported
[08:54:15.351] npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
[08:54:16.577] npm warn deprecated eslint@8.49.0: This version is no longer supported. Please see Version Support - ESLint - Pluggable JavaScript Linter for other options.
[08:54:19.132] npm warn deprecated @supabase/auth-helpers-nextjs@0.10.0: This package is now deprecated - please use the @supabase/ssr package instead.
[08:54:20.346] npm warn deprecated @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead
[08:54:20.361] npm warn deprecated @humanwhocodes/config-array@0.11.14: Use @eslint/config-array instead
[08:54:25.740]
[08:54:25.741] added 591 packages in 17s
[08:54:25.742]
[08:54:25.742] 176 packages are looking for funding
[08:54:25.743] run npm fund for details
[08:54:25.828] Detected Next.js version: 14.2.28
[08:54:25.835] Running “npm run build”
[08:54:25.948]
[08:54:25.948] > nextjs@0.1.0 build
[08:54:25.948] > npx next build
[08:54:25.948]
[08:54:26.873] Attention: Next.js now collects completely anonymous telemetry regarding usage.
[08:54:26.874] This information is used to shape Next.js’ roadmap and prioritize features.
[08:54:26.874] You can learn more, including how to opt-out if you’d not like to participate in this anonymous program, by visiting the following URL:
[08:54:26.875] Telemetry | Next.js by Vercel - The React Framework
[08:54:26.875]
[08:54:26.926] ▲ Next.js 14.2.28
[08:54:26.927] - Experiments (use with caution):
[08:54:26.927] · scrollRestoration
[08:54:26.927]
[08:54:26.996] Creating an optimized production build …
[08:54:50.287] ✓ Compiled successfully
[08:54:50.289] Skipping validation of types
[08:54:50.289] Skipping linting
[08:54:50.552] Collecting page data …
[08:54:50.992] Initializing Supabase client
[08:54:50.993] NEXT_PUBLIC_SUPABASE_URL environment variable exists: true
[08:54:50.993] NEXT_PUBLIC_SUPABASE_ANON_KEY environment variable exists: true
[08:54:51.024] ImageGenerationService initialized, default model: google/gemini-2.0-flash-exp-image-generation
[08:54:53.058] Generating static pages (0/28) …
[08:54:53.405] Generating static pages (7/28)
[08:54:53.538] Initializing Supabase client
[08:54:53.539] NEXT_PUBLIC_SUPABASE_URL environment variable exists: true
[08:54:53.539] NEXT_PUBLIC_SUPABASE_ANON_KEY environment variable exists: true
[08:54:54.216] Generating static pages (14/28)
[08:54:54.766] Generating static pages (21/28)
[08:54:55.104] ✓ Generating static pages (28/28)
[08:54:55.417] Finalizing page optimization …
[08:54:55.418] Collecting build traces …
[08:55:00.574]
[08:55:00.585] Route (app) Size First Load JS
[08:55:00.585] ┌ ○ / 5.27 kB 115 kB
[08:55:00.585] ├ ○ /_not-found 908 B 93.4 kB
[08:55:00.585] ├ ƒ /api/auth/check-sync 0 B 0 B
[08:55:00.586] ├ ƒ /api/auth/sync-session 0 B 0 B
[08:55:00.586] ├ ƒ /api/dashboard 0 B 0 B
[08:55:00.586] ├ ƒ /api/dashboard/recommendations 0 B 0 B
[08:55:00.586] ├ ƒ /api/debug 0 B 0 B
[08:55:00.586] ├ ƒ /api/feedback 0 B 0 B
[08:55:00.586] ├ ƒ /api/gift-recommendations 0 B 0 B
[08:55:00.587] ├ ƒ /api/gifts 0 B 0 B
[08:55:00.587] ├ ƒ /api/gifts/[id] 0 B 0 B
[08:55:00.587] ├ ƒ /api/recommend 0 B 0 B
[08:55:00.587] ├ ƒ /api/recommend-ai 0 B 0 B
[08:55:00.587] ├ ƒ /api/recommend-ai/queue 0 B 0 B
[08:55:00.587] ├ ƒ /api/recommend-ai/queue/status 0 B 0 B
[08:55:00.587] ├ ƒ /api/recommend-lambda 0 B 0 B
[08:55:00.588] ├ ƒ /api/recommend-page 0 B 0 B
[08:55:00.588] ├ ƒ /api/recommend-router 0 B 0 B
[08:55:00.588] ├ ƒ /api/recommend/feedback 0 B 0 B
[08:55:00.588] ├ ƒ /api/recommend/status 0 B 0 B
[08:55:00.588] ├ ƒ /auth/callback 0 B 0 B
[08:55:00.589] ├ ○ /dashboard 10.6 kB 173 kB
[08:55:00.590] ├ ○ /dashboard/calendar 5.27 kB 197 kB
[08:55:00.590] ├ ○ /dashboard/contacts 9.3 kB 204 kB
[08:55:00.590] ├ ○ /dashboard/history 6.47 kB 193 kB
[08:55:00.590] ├ ƒ /dashboard/recommendation-history 231 B 108 kB
[08:55:00.591] ├ ○ /feedback 6.44 kB 174 kB
[08:55:00.591] ├ ○ /feedback/thank-you 5.57 kB 115 kB
[08:55:00.591] ├ ○ /history 6.42 kB 160 kB
[08:55:00.591] ├ ○ /how-feedback-works 221 B 103 kB
[08:55:00.591] ├ ○ /how-it-works 4.62 kB 116 kB
[08:55:00.592] ├ ○ /login 5.47 kB 159 kB
[08:55:00.592] ├ ○ /occasions 171 B 92.7 kB
[08:55:00.592] ├ ○ /pricing 221 B 103 kB
[08:55:00.592] ├ ○ /recommend 13.4 kB 235 kB
[08:55:00.592] ├ ○ /recommend/ai-mode 5.8 kB 192 kB
[08:55:00.592] ├ ƒ /recommendation-history 231 B 108 kB
[08:55:00.593] ├ ƒ /recommendation/[id] 231 B 108 kB
[08:55:00.593] ├ ○ /relationships 3.11 kB 103 kB
[08:55:00.593] ├ ○ /settings 6.91 kB 156 kB
[08:55:00.593] └ ○ /signup 6.36 kB 121 kB
[08:55:00.594] + First Load JS shared by all 92.5 kB
[08:55:00.594] ├ chunks/4417-b63be2080f8e744c.js 53.6 kB
[08:55:00.594] └ other shared chunks (total) 38.9 kB
[08:55:00.594]
[08:55:00.595]
[08:55:00.595] ƒ Middleware 69.1 kB
[08:55:00.595]
[08:55:00.595] ○ (Static) prerendered as static content
[08:55:00.596] ƒ (Dynamic) server-rendered on demand
[08:55:00.596]
[08:55:00.827] Traced Next.js server files in: 68.63ms
[08:55:01.084] Created all serverless functions in: 257.292ms
[08:55:01.108] Error: Unable to find lambda for route: /recommend
[08:55:01.663]
[08:55:04.507] Exiting build container

We’ll need to see more code to debug this

The issue is that /recommend is being created as a static route and then for some reason it’s trying to run it as a lambda, which makes me assume there’s a mismatch in either your next.config.js or vercel.json files

If you can provide those I’ll take a look, but if that’s not enough we’ll need a full reproduction in a public repo

vercel json:{
“version”: 2,
“buildCommand”: “next build”,
“functions”: {
“app/api/recommend-lambda.js”: {
“maxDuration”: 60
}
},
“routes”: [
{ “handle”: “filesystem” },
{ “src”: “/recommend”, “dest”: “/api/recommend-lambda” }
]
}

next.config.js:/** @type {import(‘next’).NextConfig} */
const nextConfig = {
images: {
domains: [‘images.pexels.com’, ‘github.com’, ‘lh3.googleusercontent.com’, ‘placehold.co’],
dangerouslyAllowSVG: true,
contentDispositionType: ‘attachment’,
contentSecurityPolicy: “default-src ‘self’; script-src ‘none’; sandbox;”,
remotePatterns: [
{
protocol: ‘https’,
hostname: ‘**’,
},
],
},
async rewrites() {
return [
// 简化重写规则,让页面路由和API路由分开处理
{
source: ‘/api/recommend-router’,
destination: ‘/api/recommend-router/route’,
}
];
},
webpack: (config) => {
config.cache = true;

config.ignoreWarnings = [
  { module: /node_modules\/ws\/lib\// }
];

config.optimization = {
  ...config.optimization,
  splitChunks: {
    chunks: 'all',
    minSize: 20000,
    maxSize: 70000,
    cacheGroups: {
      default: {
        minChunks: 2,
        priority: -20,
        reuseExistingChunk: true,
      },
      vendors: {
        test: /[\\/]node_modules[\\/]/,
        priority: -10,
      },
      components: {
        test: /[\\/]components[\\/]/,
        priority: -30,
      },
    },
  },
  runtimeChunk: 'single',
  minimize: true
};
return config;

},
experimental: {
scrollRestoration: true,
useWasmBinary: true
},
eslint: {
// 在部署时忽略ESLint错误
ignoreDuringBuilds: true,
},
// 忽略TypeScript检查以避免构建错误
typescript: {
// 在部署时忽略类型检查错误
ignoreBuildErrors: true,
},
};

module.exports = nextConfig;

Ive made many attempts at this problem using cursor,but its still not worked.I didnt find any information about it the the vercel documentation.Can you please tell me how to solve this problem,its very important for me.thanks a lot.

You’re overriding the /recommend route in your vercel.json. I would suggest not using routes there

Instead, if you’re looking at redirecting traffic, you should use rewrites to send visitors to /recommend to your /api/recommend-lambda