content icon indicating copy to clipboard operation
content copied to clipboard

fix(module): work with nitro cache by registering routes before nitro…

Open farnabaz opened this issue 2 months ago • 7 comments

… config hook

🔗 Linked issue

resolves #3613

❓ Type of change

  • [ ] 📖 Documentation (updates to the documentation or readme)
  • [x] 🐞 Bug fix (a non-breaking change that fixes an issue)
  • [ ] 👌 Enhancement (improving an existing functionality like performance)
  • [ ] ✨ New feature (a non-breaking change that adds functionality)
  • [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

This was an attempt to solve #3613. But it seems that it works only if we move route to /api/**.

Nitro cache + server handler on modules:done hook does not work if it is not prefixed with /api /cc @pi0 @atinux

📝 Checklist

  • [ ] I have linked an issue or discussion.
  • [ ] I have updated the documentation accordingly.

farnabaz avatar Nov 18 '25 13:11 farnabaz

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
content Ready Ready Preview Comment Dec 8, 2025 5:18pm

vercel[bot] avatar Nov 18 '25 13:11 vercel[bot]

Deploying content with  Cloudflare Pages  Cloudflare Pages

Latest commit: 237125b
Status: ✅  Deploy successful!
Preview URL: https://b1a645c0.content-f0q.pages.dev
Branch Preview URL: https://fix-nitro-cache.content-f0q.pages.dev

View logs

npm i https://pkg.pr.new/@nuxt/content@3617

commit: 237125b

pkg-pr-new[bot] avatar Dec 08 '25 17:12 pkg-pr-new[bot]

@maximepvrt This PR should resolve the issue, I would appreciate if you can verify using pr-release? 🙏

farnabaz avatar Dec 08 '25 17:12 farnabaz

@farnabaz it's perfect for me ;-) Thanks !

maximepvrt avatar Dec 09 '25 10:12 maximepvrt

@farnabaz but in this branch/pk.pr.new I have error with yml parcing if I active nitro cache

 nitro: {
        routeRules: {
            '**': {
                cache: {
                    varies: ['host', 'x-forwarded-host']
                }
            },
        }
    }

[@nuxt/content 14:39:38] WARN "devenirBenevole/devenir-benevole/index.yml" is ignored because parsing is failed. Error: Cannot read properties of undefined (reading 'value')

title: Être bénévole
name: Devenir bénévole
description: Vous souhaitez vivre une expérience utile et agréable par le bénévolat ? bravo ! Peut-être avez vous une idée très précise de ce que vous souhaitez faire. Peut-être moins. Nous sommes là pour vous aider à vous y retrouver !
items:
  - title: S'engager pour une cause
    description: Découvrez les différents domaines d’activités des associations et choisissez
      de faire du bénévolat dans les causes qui vous tiennent le plus à coeur.
    to: "/devenir-benevole/domaine"
    image: "/devenir-benevole/domaine.svg"
  - title: Agir localement
    description: Les associations recherchent des bénévoles partout en France. Découvrez
      les missions de bénévolat proposées par les associations locales !
    to: "/devenir-benevole/france"
    image: "/devenir-benevole/france.svg"
  - title: Agir à tout âge
    description: Que l’on soit étudiant, jeune actif, demandeur d’emploi, femme, homme,
      retraité, diplômé, décrocheur, ou dans une toute autre situation, il y a toujours
      une bonne raison de faire du bénévolat.
    to: "/devenir-benevole/profil"
    image: "/devenir-benevole/profil.svg"
  - title: Partager ses compétences
    description: Découvrez les différentes activités dans lesquelles vous pouvez faire
      du bénévolat et partagez votre expérience et votre énergie.
    to: "/devenir-benevole/activite"
    image: "/devenir-benevole/domaine.svg"
  - title: Rejoindre une association nationale
    description: Il existe forcément une antenne locale d"une organisation nationale
      près de chez vous.
    to: "/reseau"
    external: true
    image: "/devenir-benevole/reseau.svg"

maximepvrt avatar Dec 10 '25 13:12 maximepvrt

@maximepvrt This is even stranger that original issue. Do you mind monkey patch and add a log here to show the error trace and find the line? https://github.com/nuxt/content/blob/9ddbb1097b77736fcc5c82f8080051b65f2909c8/src/module.ts#L375 Also may I have access to repo? is it public?

farnabaz avatar Dec 11 '25 12:12 farnabaz

@farnabaz I just sent you a DM on Discord regarding this.

maximepvrt avatar Dec 12 '25 18:12 maximepvrt