Does anyone know why all my api requests are hitti...
# support-questions
t
Does anyone know why all my api requests are hitting a 500 on NextJS, and my custom instance supertokens container isn't logging any requests?
r
Even your application APis? Or just supertokens related APIs?
t
Just the supertokens related APIs
r
Can I see the code for how you have used the supertokens-node middleware function?
t
src/pages/api/auth/[[...path]].ts
Copy code
import { superTokensNextWrapper } from "supertokens-node/nextjs";
import { middleware } from "supertokens-node/framework/express";
import { NextApiRequest, NextApiResponse } from "next";
import { Request, Response } from "express";
import supertokens from "supertokens-node";
import { backendConfig } from "../../../config/backendConfig";

supertokens.init(backendConfig() as any);

export default async function superTokens(
  req: NextApiRequest & Request,
  res: NextApiResponse & Response
) {
  await superTokensNextWrapper(
    async (next) => {
      await middleware()(req, res, next);
    },
    req,
    res
  );
  if (!res.writableEnded) {
    res.status(404).send("Not found");
  }
}
r
Alright. Can you surround the whole thing with try and catch and print out the exception?
t
Copy code
event - compiled client and server successfully in 586 ms (292 modules)
wait  - compiling /auth/[[...path]] (client and server)...
event - compiled client and server successfully in 162 ms (304 modules)
wait  - compiling /api/auth/[[...path]]...
event - compiled client and server successfully in 156 ms (320 modules)
error - Error: [object Object]
wait  - compiling /_error (client and server)...
event - compiled client and server successfully in 75 ms (321 modules)
error - Error: [object Object]
- for the record does the same logs without the try/catch
r
Hmm. Is there anyway you see what
[object Object]
is?
t
That's what I've been looking at - no idea where's throwing it or where's logging it
r
Hmm. Do a try catch just around
await middleware()(req, res, next);
t
Nothing - I'm going to try commenting out the whole function and just putting a test log at the start - I have a hunch
r
ok good idea
t
Ah got it - there's a problem with my config throwing an error
r
ok great!
t
All working, thanks!
p
You’re processing portion