I would like to serve files to authorized website users. How do most people do this?
Options that do NOT work:
- serving from /public (does not hit middleware)
- using a Vite ?url import (this creates a public download endpoint)
Option 1: using a Vite ?raw import
I think I can inline the binary string into the endpoint file using a Vite raw import. The downside would be that the entire binary string is immediately loaded into memory when the server loads the endpoint file. My static asset may be ~100 MB in size.
Option 2: streaming from local filesystem
In theory, I could stream from the local filesystem, but because I use third-party hosting, there may be unexpected challenges. Is copying files into the build folder /dist/server a workable solution?
Option 3: proxy a cloud storage provider
I know this would work, but I would prefer to keep all website data in roughly the same place.