Questions tagged [next-connect]
35 questions
0
votes
0 answers
How do i use next connect package with next js 13
I started an application with the latest version of Next Js and i tried to use next-connect to structure my routes because of things like middleware before routes which is how i did in version 12, here is a sample code
import morgan from…
0
votes
1 answer
Typescript error when using next-connect - This expression is not callable. Type 'typeof import(...)' has no call signatures
I am trying to implement a function where a file will be uploaded to the public folder of the nextjs app using next-connect. But getting a typescript error -
This expression is not callable.
Type 'typeof…

Nickname
- 65
- 1
- 8
0
votes
0 answers
TypeError: resolver is not a function [POST request]
Hi guys this is my user registration api code
That trying to mutate sanity user document field
It's taking user's name, email, password
All imports
import { createRouter } from "next-connect";
import bcrypt from "bcryptjs";
import axios from…

k3ydow
- 1
- 2
0
votes
1 answer
How to use authorization in NextJS API Backend?
I have working nextjs app using prisma as ORM. I have this page: /somecats which connect to nextjs backend (/pages/api/categories). When I execute http://localhost:3000/api/requests), it not require authorize. I want this endpoint should be…

bandungeuy
- 378
- 4
- 19
0
votes
1 answer
Failing to create relationship logic between two database tables using Prisma and Javascript
This is, as far as I can tell, a logic problem that I just can't wrap my head around. Using next-connect I have a function for updating an entry in the database:
.put(async (req, res) => {
const data = req.body;
const { dob, roles, cases }…

Chris Haupt
- 142
- 1
- 11
0
votes
0 answers
How to implement router middleware with next-connect v1
With next-connect version 0.13 I used a factory pattern to create router middle-ware for all endpoints.
export default function handler() {
return nc()
.use(async (req, res, next) => {
await dbConnect(MONGODB_URI);
await next();
…

nordic70
- 130
- 2
- 9
0
votes
1 answer
How to implement iron-session with session id
I am using iron-session, next-connect with nextjs in our webapp and one of the requirements is to publish analytics events from our frontend code, like page views, button clicks and other custom events. These events are stored in our database and…

JohnStephen.19
- 345
- 7
- 19
0
votes
1 answer
failed login redirects me to /api/auth/error on next-auth
I'm using next-auth v. 4.18.8 in my login page. This is the final project of my Fullstack JS course. I'm using a newer version than the one used in the course (next-auth v. 3 is used)
When I insert the correct password, everything works as it should…

João Textor
- 103
- 1
- 9
0
votes
0 answers
Redirect from client side and server side in nextJS
I am using next-connect to chain middleware inside the getServerSideProps and have the same set of middleware in the next JS API. I am calling the same using axios on client side.
How do I write a common logic in the middleware to redirect to…

c_Jane
- 1
0
votes
0 answers
Unexpected end of form when using with nextjs
I am using multer to upload the file using the nextjs. In nextjs, I have created a folder "auth" inside "api" folder. So my API path will be 'http://localhost:300/api/auth/post'.
Now I am using "next-connector" library along with multer to upload…

Jayna Tanawala
- 475
- 10
- 27
0
votes
1 answer
How to use next-connect with host proxy during development?
I am using restinio as my backend API server. Previously I used ReactJS for front-end and solved this proxying issue using "proxy": "http://localhost:4000" in package.json as documented here;…

share
- 315
- 2
- 6
0
votes
1 answer
Next Connect with-passport-and-next-connect and mongoose: req.user is undefined
I am using Next.js and have successfully added passport.js, thus getting a user back after a successful login. \0/
However what I want is the req.user to be available to my api/user route...
In this example repo in middleware/auth.js
It mentions in…

Antonio Pavicevac-Ortiz
- 7,239
- 17
- 68
- 141
0
votes
1 answer
Chaining middleware in next-connect fails with error handler
I have following two middleware functions:
function validateEmail(req, res, next) {
console.log('email validation');
if (req.body.email && req.body.email.match(EMAIL_REGEX)) {
console.log('email OK!');
return next(req, res);
} else {
…

mtx
- 1,196
- 2
- 17
- 41
0
votes
1 answer
No 'Access-Control-Allow-Origin' header is present on the requested resource. Next.js CORS error when using next-connect
I am trying to use cors in Next.js with next-connect. However, I'm unable to make it work.
Here's my cors code:
function handler() {
if (!COOKIE_SECRET || !SESSION_SECRET)
throw new Error(
`Please add COOKIE_SECRET & SESSION_SECRET to…

deadcoder0904
- 7,232
- 12
- 66
- 163
0
votes
1 answer
TypeError: resolver is not a function in `next-connect`
I have a project using next-connect & twitter-api-v2.
I have a handler which calls 2 get routes like:
export default handler()
.get('/twitter/generate-auth-link', generateAuthLink)
.get('/twitter/get-verifier-token', getVerifierToken)
The…

deadcoder0904
- 7,232
- 12
- 66
- 163