save file on file system not found
i've create api to save file to public files
after i upload new file on railway host, 404 where i acess it,
but if i upload on local host and deploy app to railway, it's work
anyone can help me
25 Replies
Project ID:
N/A
help
What server framework are you using?
next js
railway disk is ephemeral, did you add a volume?
sure
"result": [
{
"src": "../../uploads/1695115440009What-is-Generative-AI-what-are-Foundation-Models-and-why-do-they-matter-scaled.webp",
"name": "1695115440009What-is-Generative-AI-what-are-Foundation-Models-and-why-do-they-matter-scaled.webp"
},
{
"src": "../../uploads/1695137501651Pittsburgh_Pirates-Logo-PNG8.png",
"name": "1695137501651Pittsburgh_Pirates-Logo-PNG8.png"
}
],
right side is image where i upload on railway host
left side is image where i deploy it
i think it's because i use process.cwd() to find root of my app?
but i get this result from
you've to save the files on where your disk is mounted, make sure you're doing that
try to mount the volume to
/app/public/uploads
btw i mount volume /public, not /app/public
it's the problem?
try to mount the volume to the mount point I just provided
can we see container file system on railway?
maybe it store on wrong path
your app can, but railway provides no ssh or ftp access
try the mount point I provided please
ok i'll try
thanks @Brody
problem still same, i've chage /public/uploads to /public, and create volume on /public, but same
have you tried the exact mount point I gave you?
yes
but all public file not found
so i change locate file upload to /public and volume on /public
but same problem
all public file there, but when i upload new public file it'll 404
it just seems like you are getting your paths all wrong, take a step back and think all this over
solved with creating endpoint to return image
next js /public path for static file only
awesome, glad you solved it!
thanks
watch out, your code might be vulnerable if you're accepting path from the user and concatening it somewhere.
https://owasp.org/www-community/attacks/Path_Traversal