R
Railway

✋|help

Hosting a Directus + NuxtJs project service available

Eemmsii8/22/2023
I'm trying to host a Directus service and NuxtJs service but I'm having some trouble getting the frontend Nuxt service to make API calls to Directus.

I'm using the following dockerfile to run the Directus service: https://gist.github.com/matt-clegg/2ab36ff500e490ee25b17ceed1910e9e

And the following dockerfile to run the Nuxt frontend: https://gist.github.com/matt-clegg/8595a5573a1c24752026cbfd0571fa0e

I am able to deploy each service to my project successfully. I can access the Directus admin and edit collections completely fine. The Nuxt frontend is barebones at the moment, the only dependency it has is the nuxt-directus module. I've attached an image of the main .vue file, if I comment out the code to make an API call to Directus, it run's fine. However when I make the call to load a Directus collection, the frontend fails with the Railway Application failed to respond 503 error.

I've tried setting the NUXT_DIRECTUS_URL variable to both the public and private domains of the Directus service and neither work. I've also tried running just the frontend locally setting the NUXT_DIRECTUS_URL variable to the hosted public Directus service and that works fine, it just when the frontend is hosted is when it errors.
Eemmsii8/22/2023
fabe1d4a-3a95-44c1-ac1c-3e5fc8fe67c9
Bbrody1928/22/2023
send the domains for the frontend and backend please
Bbrody1928/22/2023
your frontend needs to listen on process.env.PORT this PORT is automatically assigned to your service, if you dont listen on it railway has no way of knowing how to proxy requests to your app
Eemmsii8/22/2023
Which service are you talking about? I've set PORT=3000 in my frontend service variables and PORT=8055 in my directus service variables. I can see directus running at :8055 in the deployment logs and the frontend running at :3000

Edit: Sorry, misread your message. The frontend should be listening on the port I set
Bbrody1928/22/2023
sorry you did not read what i said
Bbrody1928/22/2023
Bbrody1928/22/2023
if you had done this your log would contain some random 4 digit number instead of 3000
since railway assigns your service a random PORT variable that you must listen on
Eemmsii8/23/2023
Yeah I've already tried this, I thought hard coding port 3000 in the dockerfile and railway would help.

I've changed my dockerfile to only expose the port that is passed in, I can see in the logs the random port railway has assigned, but when I access the frontend domain it still errors with Application failed to respond
Bbrody1928/23/2023
you don't need to do anything with the port in your dockerfile, you can remove that stuff
https://github.com/railwayapp-templates/nuxtjs/blob/main/nuxt.config.ts#L37-L40
Eemmsii8/23/2023
so I removed the ARG PORT, ENV PORT ${PORT}, ENV NITRO_PORT ${PORT} and EXPOSE ${PORT} lines from the dockerfile and still no luck, it's still failing to respond.

it looks like that template is using an older version of nuxt, the way to set the port at runtime is by setting the PORT or NITRO_PORT env variables: https://nuxt.com/docs/getting-started/deployment#configuring-defaults-at-runtime

I don't think this is the issue though, as previously I have been able to access the frontend and see my changes in the browser. The issue is when the frontend tries to make an API call to the directus service.
Bbrody1928/23/2023
I can't see your frontend at all, I always get 503
can you show me your metrics for the frontend service
Eemmsii8/23/2023
sure thing
Bbrody1928/23/2023
is your frontend crashing during the api calls?
well I guess it would technically be the nitro server
Eemmsii8/23/2023
I've managed to get it working now! There was a typo in the NUXT_DIRECTUS_URL env variable name!

Thanks for your help!

Looking for more? Join the community!

Recommended Posts
DB StorageHello all, I have a question. How much storage does Railway have when building a server or databaseLogs broken?Hello is there a problem with logs? I am not seeing any build or deploy logs at all, I just see the Minecraft Server isn't working?When I use the minecraft server template and leave everything it will give this error in the logs anFormbricks Template error (upon redeployment w/ SMTP setup)``` error getting environment TypeError: fetch failed at Object.fetch (node:internal/deps/undicPayload CMS + Nextjs Deployment Failed during build processUsing the template courtesy of @Brody with Next.js added [as seen here](https://github.com/payloadcmHosting a modded Minecraft serverHi guys! I'm trying to host a modded minecraft server through Railway using the `Minecraft Server` tCan't connect to RedisThis is the error I am getting. What I have checked so far * Made sure I used the env variables provHello everyone, i'm trying to make a python websocket using websockets library also flaskso basically i have this -> ```py async def main(): url = os.environ.get('RAILWAY_URL', 'localExtension of Payment Due Date for SubscriptionIs there a way I can request for a brief extension of a few days for my upcoming payment?Hello Everyone! I am facing some problem related to deploying my nodejs application.I have deployed my nodejs application using github, but do not know how can I connect phpmyadmin so RedeployHey there, is there away to start a redploy using the Railway APIKafka Connectioncould anyone help me setup kafka cluster? I've went through the deployment process but getting a conHosting a monorepo with a Vite/Svelte Front and and a Fiber BackendI am trying to host my monorepo application within railway however I am facing some issues when tryiUnexpected timeouts and slow downsHey guys! I'm writing this post since we've been experimenting some slow downs and timeouts during tconfigure variable in VM ARGUMENTSI would like to know how do I create a variable "VM Arguments" in the railway environment? currentluhmm i think i filled the entire disk somehowservice id: 66b587c8-3c50-4dd0-8dfa-394ade04a0eci want to deploy a wordpres, is it possible?project id fb928ae2-62f0-4f8f-be68-9f7902efbebdBilled per usage plan with carryoverHey guys, I'm currently on a usage based plan but my app is only projected to use $1.70/month. Will How to use the Kafka project?I'm relatively new to Kafka and I want to publish and consume events to the Kafka running in a kafkaCannot login to Railway.app this morningHere's what I'm doing to login: I go to railway.app, and select Login enter my email address and pre