Skip to content
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

useRuntimeConfig missing when generating PDF serverside #33

Closed
digitalkaoz opened this issue Mar 11, 2024 · 4 comments · Fixed by #34
Closed

useRuntimeConfig missing when generating PDF serverside #33

digitalkaoz opened this issue Mar 11, 2024 · 4 comments · Fixed by #34
Labels
bug Something isn't working

Comments

@digitalkaoz
Copy link
Contributor

Environment

------------------------------
- Operating System: Darwin
- Node Version:     v21.2.0
- Nuxt Version:     3.10.3
- CLI Version:      3.10.1
- Nitro Version:    -
- Package Manager:  [email protected]
- Builder:          -
- User Config:      devtools, modules, formkit, colorMode, kinde, stripe, routeRules
- Runtime Modules:  @formkit/[email protected], @nuxtjs/[email protected], @unlok-co/[email protected], @nuxtjs/[email protected], @sidebase/[email protected]
- Build Modules:    -
------------------------------

Reproduction

see below

Describe the bug

when trying to generate a pdf serverside, i get this error (logs section):

the api endpoint looks like this:

import { createPDF, streamReturnPDF } from '#pdf'

export default defineEventHandler(async (event) => {
  const pdf = createPDF()
  pdf.text('Welcome to NuxtPDF!')
  pdf.end()
  return streamReturnPDF(event, pdf)
}

Additional context

No response

Logs

[nuxt] [request error] [unhandled] [500] useRuntimeConfig is not defined
  at createPDF (./node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@sidebase/nuxt-pdf/dist/runtime/server/pdf.mjs:5:36)  
  at Object.handler (./server/api/generator.ts:50:1)  
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)  
  at async Object.handler (./node_modules/.pnpm/[email protected]/node_modules/h3/dist/index.mjs:1962:19)  
  at async Server.toNodeHandle (./node_modules/.pnpm/[email protected]/node_modules/h3/dist/index.mjs:2249:7)
@digitalkaoz digitalkaoz added the bug Something isn't working label Mar 11, 2024
@digitalkaoz
Copy link
Contributor Author

it looks like this access is the problem https://github.com/sidebase/nuxt-pdf/blob/main/src/runtime/server/pdf.ts#L28

digitalkaoz added a commit to digitalkaoz/nuxt-pdf that referenced this issue Mar 11, 2024
@moshetanzer
Copy link

what is happening witbh thtis, this libary does not work on server side atm?

@digitalkaoz
Copy link
Contributor Author

it doesnt work here...the PR fixes it

@zoey-kaiser
Copy link
Member

Hi @digitalkaoz @moshetanzer 👋

I had recently begun rewriting parts of the module to provide a Nuxt wrapper for PDFKit along with some helpers. The current 1.0.0 alpha releases are not to be used in production yet!

I am still unsure about the future of this approach, or if we will find a better way to generate PDFs inside Nuxt. In #25 I had outlined some next steps for this module, but am still unsure about how much value they will actually bring.

Most of the current server side functionality could be easily added yourself in a project by installing PDFKit and then writing some helper functions. I am still thinking of ways to provide more value, before continuing to push the next release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants