-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mupdf not working with Next.js RouteHandler #90
Comments
Okay - this is not related to using Next.js or the RouteHandler - we had a previous issue here: #12 - you can also checkout the We need to figure out how to resolve this "module not found" issue, to be honest I don't comprehend the complexities around it. I will assign some engineers to this Issue who might understand this better. |
@jamie-lemon Thank you for the response and providing examples. I updated the https://github.com/arwtyxouymz/mupdf-edge-test and you can try it by: $ pnpm dev
# This causes error (using Route Handler)
$ curl http://localhost:3000/api/mupdf
# This works (using API Routes with nodejs runtime)
$ curl http://localhost:3000/api/pages/mupdf I hope this helps your investigation. Thanks. |
@arwtyxouymz @jamie-lemon I solved it by explicitly adding the mupdf wasm files in Next.js config https://github.com/mfts/papermark/blob/main/next.config.mjs#L14 Maybe that solves your issue |
Actually, I read your article and tried your solution before creating the issue. |
That's a good point. I'll try it with 0.2 and work with it |
@arwtyxouymz Thanks for the feedback - I can confirm that I can also see it working with your API Routes with nodejs runtime solution. I also don't understand this :) . All I know is that the library works fine under the node js environment, which explains why the "API routes with nodejs runtime" would work in this case. I have asked @mipo1357 to look into this issue further and hopefully he might have some ideas ( he is more of a React programmer than I am ;) ) |
Thanks for pointing out the problem. I am attempting to investigate here but am unable to provide a solution. Please give me some more time. |
@mipo1357 @jamie-lemon /** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
serverComponentsExternalPackages: ['mupdf'],
},
};
export default nextConfig; |
Thanks @arwtyxouymz for your example repo I successfully updated mupdf from I made the following changes:
next.js 14.2.4 |
Thanks for the info. I will check these actions! |
I'm running into this now, same settings as what @mfts has shared but still getting the following error on build:
|
@Southclaws bundler, next.config is set like mine above? |
I did get this working eventually on 0.2.2 inside a route handler (not a page handler) - though now we've switched to doing this in our Go backend using https://github.com/klippa-app/go-pdfium |
Hi there,
I also posted this on Discord and the member suggested me to create the issue here :)
I'm currently trying to use mupdf with Next.js RouteHandler, but I'm facing difficulties making it work. I would appreciate any help.
Overview
I am attempting to use mupdf within Next.js RouteHandler.
The test is very simple: fetch a PDF and convert it to PNG for the response.
I've tried both
runtime = edge
andruntime = nodejs
, but both result in errors.(I prefer to use
edge
runtime because my project is related to LLM work).Target file
The api is very simple. Just getting pdf file from
/public
directory, and load and convert it to png by usingmupdf
, and return it to client.Errors
runtime=edge
runtime=nodejs
How to reproduce
I create the minimum reproduce repo.
https://github.com/arwtyxouymz/mupdf-edge-test
You can try it just like this.
Updated: 06/11
I updated my repo to be able to test easily.
Thank you for your help and for maintaining this great project!
The text was updated successfully, but these errors were encountered: