Closed jsulpis closed 2 years ago
@jsulpis I didn't play a lot with Nuxt 3 generate
, but there is indeed an issue.
I still think we should keep manifest.json
on baseURL, as there's already a manifest.json
in assets
generated by Nuxt which gives information about the assets (js
/ css
).
But in the other hand, it seems Nuxt 3 recognize any href
as a route, so it tries to navigate to the manifest.json
somehow.
I'll need to have a closer look, as I don't really want to have to move it to assets and rename it to pwa.manifest.json
to not have conflict with the other manifest.json
.
Feel free to suggest a fix if you find some :)
EDIT: I tried to move it to assets, it does not fix the issue :
I think this is done by nitro
crawler : https://github.com/nuxt/framework/blob/main/packages/nuxt/src/core/nitro.ts#L52
@pi0 Do you have a clue about why Nitro is trying to crawl the manifest file ? :)
I wonder if it could be an issue in nuxt3 / nitro, because I tried to remove the link tag at the end of the meta.ts
file (which removed the error because there is no link to the manifest), then I added said link in nuxt.config.ts
:
app: {
buildAssetsDir: '/assets/',
head: {
link: [
{'rel': 'manifest', href: '/assets/manifest.f92523ca.json'}
]
}
},
and the same 404 error comes back on the manifest file. This does not seem right to me
Your configuration from your nuxt.config
is exactly what is doing this module here https://github.com/kevinmarrec/nuxt-pwa-module/blob/main/src/meta.ts#L160, so you should expect same error :)
This is just about Nitro trying to crawl a file as a route, I'd say.
The manifest link is grabbed from HTML : https://github.com/unjs/nitro/blob/main/src/prerender.ts#L112
Then it is not ignored cause json
has been tagged as allowed extension :
https://github.com/unjs/nitro/blob/main/src/prerender.ts#L10
https://github.com/unjs/nitro/blob/main/src/prerender.ts#L122
Let's wait for some @pi0 thoughts about this.
Not module issue. Prerender is experimental. If ssr is false, html will be clean and get rid of error.
@jsulpis
Closing as the problem isn't caused by this module implementation but needs to be fixed upstream.
One workaround is disabling crawler in nuxt.config
:
import { defineNuxtConfig } from 'nuxt'
export default defineNuxtConfig({
generate: {
crawler: false
}
})
This will prevent nitro
(used by Nuxt 3) to crawl links found inside generated pages.
@pi0 @danielroe We should consider doing two things :
generate.exclude
nuxt configuration to Nitro prerender to be able to opt out routes before and after crawling.rel: 'manifest'
links./cc @pi0 @danielroe
What are the next steps to fix this ? :)
I opened https://github.com/unjs/nitro/issues/308.
Great @danielroe thanks !
See https://github.com/unjs/nitro/issues/308#issuecomment-1169764262 for a recommendation for how to generate the manifest instead which would resolve this issue within this module.
@danielroe About the possible fix, It means serving manifest.json
through a Nuxt Server (Nitro) API endpoint ? i.e. a h3
event handler ?
Exactly.
Should be fixed by https://github.com/kevinmarrec/nuxt-pwa-module/commit/fa800723f86de346343a4ea434346d79beda6989.
I've tested to local serve a generated Nuxt 3 PWA app (with nuxi generate
) and it sounds to work well.
Will be available in next release.
Hello, first of all, thank you for this module ! I would like to use it with static generation and this does not seem to work.
In your repo, when I run
pnpm nuxi generate example
, I get the following error :The build output seems to be fine. However, when I move the
app.vue
file into apages
folder and rename it toindex.vue
(closer to a real world configuration), with the same command I get this error :In this case, the content of the manifest file is corrupted, so the app is not installable. Maybe the manifest file should be moved into the assets folder ? or ignored during the prerendering somehow ?
I am OK to contribute if it helps you and if you give me some indications :)