I'm currently dealing with middleware issue of "header was called outside of scope request". Not sure why this error occured, here is the middleware setup:
import {
convexAuthNextjsMiddleware,
createRouteMatcher,
isAuthenticatedNextjs,
nextjsMiddlewareRedirect,
} from "@convex-dev/auth/nextjs/server";
const isPublicPage = createRouteMatcher(["/auth"]);
export default convexAuthNextjsMiddleware((request) => {
if (!isPublicPage(request) && !isAuthenticatedNextjs()) {
return nextjsMiddlewareRedirect(request, "/auth");
}
if (isPublicPage(request) && isAuthenticatedNextjs()) {
return nextjsMiddlewareRedirect(request, "/");
}
//todo: redirect user from auth if logged in
});
export const config = {
// The following matcher runs middleware on all routes
// except static assets.
matcher: ["/((?!.\..|_next).)", "/", "/(api|trpc)(.)"],
};
here is the error log via nextjs:
Error: headers was called outside a request scope. Read more: https://nextjs.org/docs/messages/next-dynamic-api-wrong-context
and i also have problem when trying to start the convex server.
✖ TypeScript typecheck via tsc failed.
To ignore failing typecheck, use --typecheck=disable.
error: Script not found "node_modules\typescript\bin\tsc"
i know i can be fixed by using --typecheck=disable. But i wanted to know what and where is the cause of this occured. Because last time, all of these errors is not present.