Problems getting images and displaying console.log() on a Railway deployment

A request is made from the client to the server to obtain articles. In the Visual Studio Code deployment, the images are obtained and the server's console.log() messages are displayed. In the Railway deployment, the images are not obtained and the server's console.log() messages are not displayed. However, the clients are obtained. In the server's GET function, on the first line, I have a console.log() to know that I made the request to the correct route. From Visual Studio Code, it appears, but not from the Railway console. I'm using Next.js. Has anyone had a similar problem? How can I fix it?
25 Replies
Percy
Percy6mo ago
Project ID: a85b4083-30a6-432a-b467-33c809a8c6f7
agusvalori
agusvalori6mo ago
ID:a85b4083-30a6-432a-b467-33c809a8c6f7
Brody
Brody6mo ago
what is the status code of the request you get when making an api call to the app that is hosted on railway?
agusvalori
agusvalori6mo ago
The status code is 200 since it returns the articles. Now I will show you the terminal outputs from Visual Studio Code and Railway. They both have the same code and execute the same route. In Visual Studio Code, it's from localhost, and in Railway, it's from the provided one. Railway Deploy Logs: - next start - ▲ Next.js 14.0.3 - Local: http://localhost:5537 - ✓ Ready in 418ms Visual Studio Code Terminal Output: - GET catalogo/ - Database connected: * myvdescartablesdb - GET productos- categorias - GET productos- categorias - GET catalogo/
No description
Brody
Brody6mo ago
how are you running your app in vscode?
agusvalori
agusvalori6mo ago
With the nextjs npm run dev command.
Brody
Brody6mo ago
try running your app locally with the same command railway runs it
agusvalori
agusvalori6mo ago
npx next dev ▲ Next.js 14.0.3 - Local: http://localhost:3000 - Environments: .env.local ✓ Ready in 4.5s ○ Compiling /catalogo ... ✓ Compiled /catalogo in 5.5s (2538 modules) ○ Compiling /api/catalogo/categorias ... ✓ Compiled /api/catalogo/categorias in 3.1s (1355 modules) ✓ Compiled (1357 modules) GET catalogo/ GET productos- categorias Base de datos conectada: * undefined Base de datos conectada: * myvdescartablesdb ✓ Compiled /api/catalogo/[articuloID]/imagenes/[imageName] in 298ms (1359 modules) GET catalogo/ GET productos- categorias Base de datos conectada: * myvdescartablesdb Base de datos conectada: * myvdescartablesdb
Brody
Brody6mo ago
try running your app locally with the same command railway runs it
agusvalori
agusvalori6mo ago
No description
Brody
Brody6mo ago
I assume you need to build it first
agusvalori
agusvalori6mo ago
I managed to build the app and also added in Railway that I used the same command npx next build. The issue I'm facing is that it doesn't show me the commands. The strange thing is that if I perform a NextResponse, I can get it from the client, but it doesn't show me the console.log(). In fact, I simplified the GET function to a NextResponse and a console.log, and that's what happens. const GET = async () => { console.log("GET catalogo/"); return NextResponse.json({ message: "GET catalogo/", data: [], }); } export { GET }; In the client's server, I get the correct message, but in the terminal, I don't see the console.log().
Brody
Brody6mo ago
so the app does work as designed, its only that you arent seeing those console.log()'s?
agusvalori
agusvalori6mo ago
Yes. It works fine, it's just that I can't see the console.log() messages, and then when I put the complete code, some images in the articles don't load. I have the same code in another route, but the difference is that when fetching the articles from MongoDB, it only gets the articles that match a subcategory. const products = await Product.find() const products = await Product.find({ CATEGORIA: categoriaName}) And this one does show all console.log() messages and the images on the client.
Brody
Brody6mo ago
when you run the app with npm run start locally, are you seeing the console logs?
Want results from more Discord servers?
Add your server