404 error on some endpoints when deploying to Vercel
valentintorres02 opened this issue · 2 comments
Hi!
My routes are working fine at localhost (next dev and next start). But when I deploy everything to Vercel, I have an [promptId].ts endpoint that returns a 404 error (and it's just a blank response, I'm not even getting the next html error page)
The other routes without params work fine. My code:
// pages/api/prompt/[promptId].ts
import { PromptService } from "api/services/prompt.service";
import { EditPromptInput } from "common/dto/prompt";
import {
Body,
createHandler,
Delete,
HttpCode,
Param,
Patch,
ValidationPipe,
} from "next-api-decorators";
class PromptRoutes {
private readonly promptService: PromptService;
constructor() {
this.promptService = new PromptService();
}
@Delete("/:promptId")
@HttpCode(200)
public async delete(@Param("promptId") promptId: string) {
const deletedPrompt = await this.promptService.delete(parseInt(promptId));
return deletedPrompt;
}
@Patch("/:promptId")
@HttpCode(200)
public async edit(
@Param("promptId") promptId: string,
@Body(ValidationPipe) body: EditPromptInput
) {
const data = body;
const editedPrompt = await this.promptService.edit(parseInt(promptId), data);
return editedPrompt;
}
}
export default createHandler(PromptRoutes);
I have path-to-regexp
v6.2.1 installed.
ts.config.json:
{
"compilerOptions": {
"target": "es6",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"experimentalDecorators": true,
"jsx": "preserve",
"incremental": true,
"baseUrl": ".",
"paths": {
"@components/*": ["components/*"],
"@styles/*": ["styles/*"],
"@hooks/*": ["hooks/*"],
"@interfaces/*": ["interfaces/*"],
"@images/*": ["public/images/*"],
"@content/*": ["content/*"],
"@lib/*": ["lib/*"],
"@pages/*": ["pages/*"]
},
"emitDecoratorMetadata": true
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
I have a standard Next.js app with standard Vercel deploy. Please let me know if you need any more data. Thanks in advance =)
Example request that works on localhost and does not work on vercel:
URL: https://twitter-automated-bot.vercel.app/api/prompt/14
BODY: {"priority": 0, "text": "something"}
Created a fresh project and deployed, but couldn't replicate your problem. Please provide a minimum reproducible repository.
Closing. Please feel free to re-open when you have a minimum reproducible repository.