pdfmake import not working in nextjs app router

66 Views Asked by At

I want to use pdfmake in next js backend api here is the way I'm using it.

import { options } from "@/app/api/auth/[...nextauth]/options";
import { getServerSession } from "next-auth";
import { NextResponse } from "next/server";
import PdfPrinter from "pdfmake";

export async function POST(req, { params }) {
  console.log("POST /api/admin/reports/create");
  try {
    const session = await getServerSession(options);
    if (!session) {
      return NextResponse.json(
        { message: "No session found, please login" },
        { status: 401 }
      );
    } else {
....

ref: https://pdfmake.github.io/docs/0.1/getting-started/server-side/ it is return this with 404 status enter image description here

If i just remove this import, the api is working fine.

"pdfmake": "^0.2.9",

next js app router

want to use pdfMake library in next js api app router. The same lib is working fine on client side.

0

There are 0 best solutions below