Hi, My api functions returns 404 on vercel. Locally in dev or build mode these are working fine.
"next": "14.0.4"
next config:
/** @type {import('next').NextConfig} */const nextConfig = { reactStrictMode: false,};
module.exports = nextConfig;For example: GET /api/accounts/me
/pages/api/accounts/[...params].ts
import type { NextApiRequest, NextApiResponse } from 'next';
import Accounts from 'api/accounts';import { getTokenFromBearer } from 'lib/auth';import { Account } from 'types/accounts';
type RouteHandler<T> = (this: Accounts) => Promise<T>;
export default async function handler( req: NextApiRequest, res: NextApiResponse) { const { method, query } = req; const params = Array.isArray(query.params) ? query.params : []; const routeKey = `${method}${params.length > 0 ? '/' + params[0] : ''}`;
const token = getTokenFromBearer(req.headers['authorization'] as string); const accountsInstance = new Accounts(token);
// eslint-disable-next-line @typescript-eslint/no-explicit-any const routeToMethod: { [key: string]: RouteHandler<any> } = { 'GET/me': accountsInstance.getMe as RouteHandler<Account>, };
if (routeToMethod[routeKey]) { try { const result = await routeToMethod[routeKey].call(accountsInstance); res.status(200).json(result); } catch (error) { //TODO: Handle errors, e.g., unauthorized, not found, etc. res.status(500).json({ error: 'Internal Server Error' }); } } else { res.setHeader( 'Allow', Object.keys(routeToMethod).map((r) => r.split('/')[0]) ); res.status(405).end(`Method ${method} Not Allowed`); }}