nuxt: Unable to serve static files after build
Environment
- Operating System:
Darwin - Node Version:
v16.14.0 - Nuxt Version:
3.0.0 - Nitro Version:
1.0.0 - Package Manager:
npm@8.19.3 - Builder:
vite - User Config:
modules,build,runtimeConfig - Runtime Modules:
@nuxtjs/tailwindcss@6.1.3 - Build Modules:
-
Reproduction
Describe the bug
Files which are added to .output/public after the build process are not accessible (already discussed here #8027).
Additional context
No response
Logs
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 18 (8 by maintainers)
Thanks for the suggestion. I have went with a different solution by just creating a data folder where I am uploading all the files to and added the following route to serve them:
So I am able to access an image over
http://localhost:3000/file/logo.png.I also encountered a variety of problems, the framework is really not suitable for production environments. For your problem, I solved it with the configuration of nginx:
Same @miclgael I spent hours browsing through nuxt, nitro and unstorage docs and trying multiple solutions with no luck. decided to go completly static build with (ssr: false). simple directory webserver. frontend browser fetch to a json file.
This solution didn’t work for me
you can use https://github.com/unjs/unstorage/ together with Nitro to make that work ☺️
ah yes, you can’t add content to
.output/publicafter build (and serve the content with your nitro server). We perform a lot of optimisations to make the server efficient, and one of them is only serving content that was present before the build.