R
Railway

✋|help

Please my images are not displaying after deploying on railway. I am new in web development.

Jjoe2279/18/2023
Please I am new to web development and first time deploying to railway. I have django drf backend with react.js frontend. My images are not displaying when i deploy it on railway. Please any help
Jjoe2279/18/2023
N/A
Jjoshmo_dev9/18/2023
hi
are you using a custom dockerfile
Jjoe2279/18/2023
No please, the deployment is done through github and is handle by railway.
Jjoshmo_dev9/18/2023
do they display locally
Jjoe2279/18/2023
yes...when i use Debug= True, in my localhost, everything works well. but when i deploy to railway, the media links is 404
Iiceman42309/18/2023
I've literally just solved this exact problem in the last hour
are you using volumes?
https://docs.railway.app/reference/volumes
Jjoe2279/18/2023
No Please, I am not using volumes. I am new to web development and my first time of using railway. Any help is welcome
Iiceman42309/18/2023
The link I sent you shows how to set up a volume
Just set that up and then I'll tell you what to change in your Django project
Jjoe2279/18/2023
I have created the volume and attach it to my django project
Iiceman42309/18/2023
Ok, now you need to no to back to your Dango project and change the settings
MEDIA_URL = 'media/' MEDIA_ROOT = os.environ["RAILWAY_VOLUME_MOUNT_PATH"]
You've probably got something like this in your urls.py file to serve your media files locally:
urlpatterns = [ # ... the rest of your URLconf goes here ... ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
change it to this:
urlpatterns = [
# ... the rest of your URLconf goes here ...
] + [ re_path(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT})]
The last thing to do is go to your newly created volume and change the mount path to "/app/media" or whatever you want to call that folder
Then it should work
Jjoe2279/18/2023
Please I am having error with the MEDIA_ROOT = os.environ["/media"] line of code in my settings. any help
Iiceman42309/18/2023
Media root is this:
MEDIA_ROOT = os.environ["RAILWAY_VOLUME_MOUNT_PATH"]
import os (if you haven't already)
just use the environment variable that Railway gives you
Anyway, good luck with this. I'm logging off
Jjoe2279/18/2023
it didn't work or maybe I couldn't configure it well.
Iiceman42309/19/2023
You need to make sure that the MEDIA_ROOT and MEDIA_URL are configured properly
As well as that urlpatterns list
Just double check them
Also, make sure that your volume is actually working ie. that the usage is going up when you try to upload something. You can see that in the metrics

Looking for more? Join the community!

Recommended Posts
ISO 27001Hi this might be a dumb question but does Railway have the ISO 27001 certification or is that irreledeploying react with viteI've deployed a react app with vite, exposing network ip but I can't access it - says Application faOpenSSL error when using Bun + PrismaGetting an error when using Bun and prisma together. Prisma requires node to work, so start command Server isnt workingThe server suddenly stopped working. Could anyone explain what is going on?...How to deploy a project with multiple dockerfiles?Have project that has one `Dockerfile` for the backend service and another one `Dockerfile.celery` fWildcard DNS let user custom there domainI would like to know how to let's my users custom domain with CNAME to my domain DNS my DOMAIN CNABun with turborepo supportHey guys, Just switched over to bun from fastify but having some trouble setting it up properly to How does pro plan upgrade works for application? particularly Spring boot app...Hi all, I find it difficult to understand how pro plan upgrade works. I upgraded my Spring boot app Deploying Rust tries to copy binaries that don't exist.I'm not using my own nixpacks.toml, and railway is attempting to copy binaries that it doesn't need Cron skipingSo my Cron Schedule keeps skipping every time?Request to free up custom domainMy project id : 5df73bd5-7d04-40dd-9e57-97f1cdd89a60 Can u pls delete the given custom domain, it sPR PreviewsHi everyone. Is it possible to setup PR previews with it's own set of environment variables?Looking for way to run LibreTranslate as a service on railwayI'm looking for a way to run https://libretranslate.com on my railway instance. Ideally it would beRTT to nearby datacenter has gone way up in the past few daysRegions have been amazing and are super helpful for our use case. We host our database in AWS us-easPublishing .net 7 app - project file not foundHi, I'm new in railway and i'm faced with file structure problem. I heared that way to publish is sIssue with staging: The value needs to be expressed as a valid JSON string.i'm trying to make a dev and product env's, but now i created a service on the dev env and trying toIssue with staging: The value needs to be expressed as a valid JSON string.i'm trying to make a dev and product env's, but now i created a service on the dev env and trying toUse Volume with grafana will permission deniedI was configed volume and data path, but when i start my grafana, it will crash. This is log: Error:if i disconect an account of github ?whats going on with the repository are linking with this account ? fb928ae2-62f0-4f8f-be68-9f7902efCommunication between projects without requestsHey everyone, a question. Is it possible to establish communication between projects? For example, I