Application failed to respond
andres-vr
FREEOP

9 months ago

My project deployed successfully, but it throws an error in the browser.

Solved$5 Bounty

52 Replies

andres-vr
FREEOP

9 months ago

d9a138f0-83d2-4162-8ed9-905775d3273a


grillekkj
FREE

9 months ago

can you share the error?


andres-vr
FREEOP

9 months ago

1407062354113335446


grillekkj
FREE

9 months ago

Can you get the deploy logs?


andres-vr
FREEOP

9 months ago

1407062783291424838


andres-vr
FREEOP

9 months ago

1407062882637713630


andres-vr
FREEOP

9 months ago

1407062900467830887


grillekkj
FREE

9 months ago

On that same page, click "view logs" it will open a tab with "details", "build logs", "deploy logs" and "https logs", can you show me all of those?


andres-vr
FREEOP

9 months ago

These are the deploy logs, i'm not mentioning localhost anywhere in the dockerfile:

FROM node:18

WORKDIR /app

COPY package.json package-lock.json ./

RUN npm install

RUN npm install -g serve

COPY . .

ENV NODE_ENV=production

EXPOSE ${PORT:-5173}

CMD if [ "$NODE_ENV" = "development" ]; then

npm run dev -- --host 0.0.0.0 --port ${PORT:-5173};

else

npm run build && serve -s dist -l ${PORT:-5173} -L;

fi

1407064469342912624

1407064469607288913


andres-vr
FREEOP

9 months ago

Also I just migrated from Vercel and it used to work on there, so unsure what causes the issue here.


9 months ago

I don't think this user needs to provide their logs, all that should be needed is a read through on our docs page for this error:


andres-vr
FREEOP

9 months ago

Thanks, I'll check it out


grillekkj
FREE

9 months ago

On your service, under settings, on Networking can you check your using the right port?


grillekkj
FREE

9 months ago

Sorry... I was just trying to understand the errors here, didnt know about that page but it might be redirect ports on networking


andres-vr
FREEOP

9 months ago

Yep, I had changed the port to vite's default instead of railway, thanks!


grillekkj
FREE

9 months ago

No problem, glad we got it sorted!


9 months ago

Please don't run a development server, that's going to be costly and unstable.


andres-vr
FREEOP

9 months ago

It's for production dw


9 months ago

If you have Vite handling the traffic, it is not for production.


andres-vr
FREEOP

9 months ago

I use vite in development but I'm using this line to call the backend in prod now: const domain = import.meta.env.PROD

? "http://backend.railway.internal:8080"

: "http://localhost:5000";

Is that fine or am I still doing something wrong?


9 months ago

If you are using vite anywhere but locally, something is being done wrong.

The community can help you here, but it might be as simple as switching to Railpack.


9 months ago

Brody isn't talking about how you call your backend, he's talking about how you are serving your frontend.

If you are serving it with vite (while in production), then you are running a development server which isn't optimal and should be used only on development.

You need to build your frontend for that, so it produces an application bundle ready to be served in prod.


9 months ago

You can check docs about it here: https://vite.dev/guide/build


9 months ago

And as Brody said, you can try using Railpack (Railways own builder) for that



9 months ago

As a starting point, you can try removing the Dockerfile, that way Railpack will be used to build your frontend.


andres-vr
FREEOP

9 months ago

Is there a way to just disable docker in prod but keep it in dev?


andres-vr
FREEOP

9 months ago

ah nvm I can just gitignore the dockerfile


9 months ago

Vite should be only used locally according to your setup


andres-vr
FREEOP

9 months ago

I see, but I don't know what to change for that, new to docker and vite, right now I've gitignored the dockerfiles

This is my vite config

import { defineConfig } from 'vite';

import vue from '@vitejs/plugin-vue';

import path from 'path'

export default defineConfig({

plugins: [

vue(),

],

server: {

proxy: {

'/api': {

target: 'http://localhost:5000', // Backend server URL

changeOrigin: true, // Needed for virtual hosted sites

rewrite: (path) => path.replace(/^/api/, ''), // Rewrites the path to remove '/api'

},

},

host: '0.0.0.0', // Docker access

port: 5173,

watch: {

usePolling: true,

},

optimizeDeps: {

include: ['lucide-vue-next', 'firebase/auth', 'firebaseui'],

},

},

});


9 months ago

Let's start by removing the Dockerfile and seeing if Railpack successfully builds it


andres-vr
FREEOP

9 months ago

Okay, will test that


andres-vr
FREEOP

9 months ago

frontend deployed using railpack, backend tried to deploy but crashed:

1407085969194356766


9 months ago

Let's start with your frontend first


9 months ago

Keep the backend on a Dockerfile for now


andres-vr
FREEOP

9 months ago

Okay, anything else I need to change?


9 months ago

Did it deploy fine? is everything working as it should?


andres-vr
FREEOP

9 months ago

Will see


andres-vr
FREEOP

9 months ago

it works now


9 months ago

Cool! now we can talk about your backend, how are you deploying it? Mind sharing the Dockerfile?


andres-vr
FREEOP

9 months ago

Sure


andres-vr
FREEOP

9 months ago

FROM node:18-alpine

WORKDIR /app

COPY package*.json ./

RUN npm ci

COPY . .

ENV NODE_ENV=production

ENV PORT=8080

EXPOSE 8080

CMD if [ "$NODE_ENV" = "development" ]; then

npm install -g nodemon && nodemon server.js;

else

node server.js;

fi


9 months ago

You are running nodemon, which is also only used for development purposes


andres-vr
FREEOP

9 months ago

yeah but thats if the env mode is development, which should be prod on railway


9 months ago

oh ok.


andres-vr
FREEOP

9 months ago

not sure if this works for railway tho, but I believe it did on vercel


9 months ago

does it show any nodemon related log in the logs?


9 months ago

Something like [nodemon] starting sucrase-node index.js or any other log that mentions nodemon at all? otherwise seems like you're prod ready!


andres-vr
FREEOP

9 months ago

it indeed doesn't mention nodemon anywhere


andres-vr
FREEOP

9 months ago

Thanks for your help!


9 months ago

Then ur good to go <:salute:1137099685417451530>


9 months ago

!s


Status changed to Solved medim 9 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...