Nuxt3; 存储在公共文件夹中的已上传文件无法找到,尽管其他文件可以找到。

huangapple go评论86阅读模式
英文:

Nuxt3; Files uploaded and stored in public folder cannot be found even though other ones can

问题

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?

Full project - https://github.com/kgarchie/Ticketer

I tried searching online, but I can't seem to find a solution.

英文:

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?

Full project - https://github.com/kgarchie/Ticketer

I tried searching online, but I can't seem to find a solution

答案1

得分: 1

我决定建立一个 API 端点来提供文件,而不是试图让 Nuxt 来提供它们。似乎 public 目录中的文件是静态的,不太可能会改变。

英文:

I resorted to building an api endpoint to serve the files, instead of trying to make nuxt serve them. It seems the files in the public directory are static and not expected to change.

huangapple
  • 本文由 发表于 2023年5月18日 03:12:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/76275493.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定