24 questions
0
votes
2
answers
290
views
Issue with Next.js 15.13 with promises and params
Writing a dynamic api route for page that accepts [slug] params.
export async function GET(request: NextRequest, { params }: { params: Promise<{ slug: string}> }) {
const {slug} = await ...
1
vote
1
answer
369
views
Cookie is not being set in Next.js route handler
I am trying to set a cookie via a route handler in Next.js (15) but while the login function I have in said handler works, the set cookie function is not doing anything.
This is the code I have:
app/...
0
votes
0
answers
62
views
How to create API with multiple text and file Fields in Next JS 14 with multer?
I am working on an API in Next.js 14+ where I need to upload files. Here are the fields I am using:
name: string
description: string
profile_picture: single image
documents: multiple files
images: ...
4
votes
3
answers
1k
views
"Next.js TypeScript error: 'param_type.params' incompatible with 'ParamCheck<RouteContext>' during build"
I am working on a Next.js project with TypeScript and Prisma. When running npm run build, the build fails with the following error:
Type error: Type '{ __tag__: "GET"; __param_position__: &...
0
votes
0
answers
100
views
Getting 404 (Not Found) error when posting to /api/message in Next.js
I'm encountering an issue with a Next.js API route. I'm making a POST request to the /api/message endpoint, but it returns a 404 Not Found error. Here’s the context:
File Structure:
The API route is ...
0
votes
0
answers
187
views
Implementing Real-time Speech-to-Text Transcription using AWS Transcribe with Next.js API Routes
I want to create an API for speech-to-text transcription using AWS SDK v3's AWS Transcribe with Next.js API Routes.
I tried to create the following API and hooks based on this reference code, but the ...
1
vote
1
answer
2k
views
Accessing User-Agent from Next.js Route Handler?
I'm trying to access a request's User-Agent header from a route handler I have on my next.js project.
Here is an example:
import { userAgent } from "next/server";
export const dynamic = &...
0
votes
1
answer
781
views
NestJS + NextJS for Authentication. New Architecture?
I'm new to NestJS and I'm trying to create a JWT-based authentication system. I want to generate a JWT token and manage it on the server side. I'm using Next.js on the frontend, so I was wondering if ...
0
votes
0
answers
120
views
I am able to receive the error from an Api call in my backend but it fails to show when i read it from the frontend in Next JS
My backend with NextJS
export async function DELETE(
req: Request,
{ params }: { params: { productId: string } }
) {
try {
const storeId = '665a238f72ab3f9616e1a1d8';
const product = ...
0
votes
1
answer
864
views
getting api routes in NextJs (App router) to respond with JSON {ok:false} when an error is thrown
I use fetch() api routes to populate my dashboard page with data. During development I adopted a plan to use try {} catch {} blocks to handle and catch errors, and then pass the error message to a ...
1
vote
1
answer
4k
views
How to properly send a blob or file as api response in next 13
I am trying to send a blob (will be a file from another API in future) as the response for a api call in next13 api routes. My handler goes like:
export default async function handler(req, res) {
...
0
votes
0
answers
115
views
Error occurred while saving user data: TypeError: req.json is not a function
Node Backend
import { NextResponse } from "next/server";
import User from "../../models/post";
const POST = async (req, res) => {
try {
const body = req.json();
...
0
votes
2
answers
477
views
NextResponse not returning data to the frontend?
This API calculates the BMI and sends it to the frontend. I have tried console logging the response, but it does not have the BMI in it. I assume this is because of some unsynchronous behaviour.
This ...
0
votes
1
answer
88
views
Creating a function that gets a server cookie for authentication in NextJS14
I am trying to implement an email address verification feature when someone registers my NextJS website with a WordPress installation as a headless CMS. To do this I want to do the following:
Setting ...
1
vote
1
answer
2k
views
NextResponse returning 200 while the response from the endpoint is 400
I was using Route Handler for fetching from external endpoint. The external endpoint is returning status 400 or any error, but when I locally hit API from the client component (e.g /api/route.ts) I ...
3
votes
0
answers
285
views
Nextjs 14.1 Build Errors Module not found : "fs"
My (Nextjs) project has a dependency on a external package which exports mostly browser compatible code but also exports some utility function that depend on some nodejs specific modules (for e.g. &...
0
votes
1
answer
849
views
Even Simple Next.js API timeout on Vercel
Every API in the NextJS project is giving a 504 bad gateway time out error only in vercel production deployment, everything works fine in local, so I added a hello GET API with the sample code.
export ...
0
votes
0
answers
300
views
The api routes are not being called on Next js
I cloned this https://github.com/naufaldi/next-landing-vpn/tree/main repo and trying to add backend to it.
So this is my folder structure. There was no app directory. so I added it and made a route. ...
1
vote
5
answers
12k
views
Integrating Socket.io with Next.js 14 /api Routes
I'm currently working on a project using Next.js 14 and I'm facing challenges integrating Socket.io with the /api routes. I've explored various resources but haven't found a clear and concise guide on ...
0
votes
0
answers
53
views
Getting an error when building a next project
I have a nextjs project that I call a fake api like jsonplaceholder. everything is ok when I run dev and start it's build.
If i change the the api address to the wrong one in purpose, I get error and ...
0
votes
0
answers
134
views
Vercel production environment post handle function cause get handle function response error data in nextjs13
The GET and POST handle functions are written in the api/nav/route.ts file at the same time. The development environment is normal. However, after deployment through vercel, the GET request returns an ...
1
vote
1
answer
3k
views
Export a named export for each HTTP method error when submitting form to API [duplicate]
I've successfully connected my app to a postgres database - using prisma (I've set up a seed.ts file, pushed it and the data is sent to the database).
The problem I'm having is creating the api ...
0
votes
1
answer
3k
views
Next Js Response Header redirection
Objective:
What I am trying to achieve: With a button click from a page the req will reach the controller. The controller will set some cookie, when the response will redirect the page to another ...
0
votes
1
answer
341
views
NextJS with "openai api" got 401 error at endpoint createChatCompletion() but 200 ok at createCompletion()
In short
NextJS api router failed to call openai api endpoint createChatCompletion() while pure Node.js code can succeed.
Detail
I use NextJS 's api router as coded here to call "openai api" ...