uploads module, you need to decide where files live in production before the first upload. The module doesn’t move files between providers, so switching later means migrating them yourself.
The module stores files wherever STORAGE_PROVIDER points:
local(default): a directory on the server’s disk;s3: any S3-compatible object storage.
GET /api/uploads/<id>, never directly from storage, so the bucket can stay private.
Choose a location
What production enforces
WithNODE_ENV=production (always true in the Docker image), the startup env check refuses configurations that would lose files:
“On Railway” means
RAILWAY_ENVIRONMENT_ID is set; Railway sets it for you. Any of these errors makes the server exit with code 1 at startup. The kit can’t check whether a directory actually survives a redeploy; that is up to you.
Railway Bucket
1
Create the bucket
Add a bucket to your Railway project and pick its region. You can’t change the region later. The real bucket name is the display name plus a short hash, for example
my-bucket-jdhhd8oe18xi.2
Reference its variables from the app service
Replace
<bucket> with the bucket’s name in the project:3
Leave path-style off
Don’t set
S3_FORCE_PATH_STYLE. Railway Buckets use virtual-hosted addressing (bucket name in the hostname). Only buckets created before Railway switched to this style may need S3_FORCE_PATH_STYLE=true.Railway volume
1
Attach a volume
Attach a volume to the app service with mount path
/app/volumes/uploads. The image creates that directory for the nextjs user.2
Leave the path unset
Don’t set
STORAGE_LOCAL_PATH, and leave STORAGE_PROVIDER unset or local. Railway sets RAILWAY_VOLUME_MOUNT_PATH on a service with a volume, and the module uses it as the storage directory. If you do set STORAGE_LOCAL_PATH, it must point inside the volume.3
Grant write access
Set
RAILWAY_RUN_UID=0. Railway documents permission issues for images that run as a non-root user (here nextjs, UID 1001) on mounted volumes; this variable runs the process as root.Your own server
Local disk
The image setsNODE_ENV=production, so local outside Railway needs an absolute STORAGE_LOCAL_PATH. Mount a persistent volume at the directory the image prepares:
nextjs (UID 1001):
- A new, empty named volume mounted at
/app/volumes/uploadsinherits the directory’s ownership from the image, sonextjscan write to it. - A named volume mounted at a path the image doesn’t prepare fails with
Permission denied. - A reused volume whose files belong to root keeps its owner, and the first upload fails with
500 storage_failed. Fix the ownership withchown -R 1001:1001. - A host directory (
-v /srv/uploads:/app/volumes/uploads) must be writable by UID 1001.
s3.
S3-compatible storage
Any S3-compatible service works: AWS S3, Cloudflare R2, MinIO, Backblaze B2 and others.Local development
Locally,.env.example uses local with ./volumes/uploads. To try the S3 path, start MinIO with the s3 Compose profile; it creates the <slug>-uploads bucket for you:
STORAGE_PROVIDER=s3 in .env. MinIO is for development and CI only; it isn’t part of the production image.
Related
Uploads module
What the module does and how to use it in features.
Deploy on Railway
The full Railway setup.