agusvalori
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?
26 replies
Issue with Saving Product Images to Railway Volume
Issue with Saving Product Images to Railway Volume
Hello everyone!
I'm having trouble trying to save product images to a Railway volume. The situation is as follows: when I save the data in the path /src/uploads, I don't see any changes in the volume metrics. Additionally, every time the server reloads during a deployment, the data gets deleted. What steps should I take to resolve this?
In Railway, my volume connection is configured as follows:
Mount Path: /src/uploads/
To save the images, I'm using the following code:
const rootImagePath = ${process.cwd()}/src/uploads/images;
// Check if the folder exists, and if not, create it
await access(directoryPath, constants.R_OK)
.then(() => console.log("Directory exists"))
.catch(async (error) => {
console.log("Requested directory does not exist: ", error.message);
// Create the directory recursively if it doesn't exist
await mkdir(directoryPath, { recursive:true }); });
const filePath = path.join(directoryPath, imageFile.name);
// Save the file to the directory
await writeFile(filePath, buffer);
nextjs, railway14 replies