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

useStrapi breaks npm run generate #417

Open
kasperjha opened this issue Jun 10, 2024 · 0 comments
Open

useStrapi breaks npm run generate #417

kasperjha opened this issue Jun 10, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@kasperjha
Copy link

kasperjha commented Jun 10, 2024

Version

@nuxtjs/strapi: v1.12.0
nuxt: v3.11.2

Reproduction Link

https://github.com/kasperjha/nuxtjs-strapi-generate-issue

In app.vue you'll find the following:

<template>
  <div>
    <h1>@nuxtjs/strapi payload extraction test</h1>
    <p>Data from the "test" collection should be prerendered below</p>
    <code>{{ data }}</code>
  </div>
</template>

<script setup lang="ts">
// this breaks on `npm run generate`
const strapi = useStrapi()
const data = await strapi.findOne('test');

// this useFetch example works as expected
// const strapiUrl = useStrapiUrl()
// const data = await useFetch(strapiUrl + '/test');
</script>

Steps to reproduce

  • Create a test collection in your strapi instance
  • Clone the repo, install dependencies and point the STRAPI_URL env variable to your instance
  • Execute npm run generate in your terminal

The command fails

  • (optionally) verify no failure when using commented example code instead

What is Expected?

I expect no errors to be thrown when running npm run generate.

What is actually happening?

npm run generate fails with the error messages

...
Errors prerendering:
[nitro 1:06:18 AM]   ├─ / (65ms)
  │ └── Error: [500] 
[nitro 1:06:18 AM] 

[1:06:18 AM]  ERROR  Exiting due to prerender errors.

  at prerender (node_modules/nitropack/dist/chunks/prerender.mjs:218:11)
  at async node_modules/nuxt/dist/index.mjs:3471:7
  at async build (node_modules/nuxt/dist/index.mjs:5001:5)
  at async Object.run (node_modules/nuxi/dist/chunks/build.mjs:95:5)
  at async Object.run (node_modules/nuxi/dist/chunks/generate.mjs:56:5)
  at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.9edf0930.mjs:1648:16)
  at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.9edf0930.mjs:1639:11)
  at async runMain$1 (node_modules/nuxi/dist/shared/nuxi.9edf0930.mjs:1777:7) 

[1:06:18 AM]  ERROR  Exiting due to prerender errors.
...
@kasperjha kasperjha added the bug Something isn't working label Jun 10, 2024
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

No branches or pull requests

1 participant