kgarchie / Ticketer

Links
Other
1 stars 2 forks source link

I also meet the same question, have u resolved it ? #3

Closed ixyzorg closed 2 months ago

ixyzorg commented 3 months ago

I am using nuxt 3 to create a web app where users can upload files. For now, I store them in the public folder where I assumed they would get served to users

Other files like favicon get served but not the uploaded files, I get a 404 error, during yarn dev it seems to work fine but not after building with yarn build. this is screenshot of the folder the favicon.ico, can be accessed but not the newly uploaded screenshot. How can I mitigate this?

I also meet this question, have u resolved it ?

kgarchie commented 3 months ago

Hello, yes.

So turns out it only works in the dev server because in production, Nuxt caches the contents of the public folder, thus any new content will not be available.

If in production just use Nginx to serve the files, or create an endpoint to serve the files manually,

Also note: If you choose to write endpoints to serve the files manually, you will need to enable read and write permissions on the folder you are going to use, also, it won't work on platforms that build edge functions like Vercel.

kgarchie commented 3 months ago

For this project, I decided to write a custom driver using https://unstorage.unjs.io/ to read, write and store my files. It's quite versatile. It's not fully working however.

ixyzorg commented 3 months ago

thanks, my project also use https://unstorage.unjs.io/ to storage my file in public, I will try the nginx reverse proxy pulic folder). this is my project https://github.com/ixyzorg/nuxt-blog-ts.git god blesh U thanks