diegomura / diegomura/react-pdf
Assets cannot resolve when using Node API in NextJS API route
- Dominant language
- TypeScript
- Stars
- 16.8k
- Forks
- 1.3k
- Avg merge
- 5h 6m
- Merged PRs (30d)
- 52
Description
**Describe the bug**
I cannot use the Node rendering API on NextJS, as everytime I try to register a Font or use an Image, the path to the asset fails to be found or is resolved incorrectly internally on the library.
**To Reproduce**
Steps to reproduce the behavior including code snippet (if applies):
1. Create an API route in NextJS
2. Render a file using the `renderToFile` function in the API route. The file should contain some local fonts to be registered or images to be displayed.
3. See error - the assets and font paths resolve incorrectly. I have tried using Node's `process.cwd()` to set the asset paths to the absolute path within the project.
**Expected behavior**
The assets and font paths resolve incorrectly. I have tried using Node's `process.cwd()` to set the asset paths to the absolute path within the project, however the `not_found` error thrown, logs the incorrect absolute path - it is as if the given absolute path changes when the document is being rendered using the Node API.
**Desktop:**
- OS: [ Windows]
- Browser : [Chrome]
- React-pdf version [v3.1.9]
Contributor guide
Assessment
This issue has not been assessed yet.