8 months ago
Successfully deploy, but got the below error
Failed to load resource: the server responded with a status of 502 ()
I tried to run locally the frontend, and link to the backend that deployed in railway, it works, can you please help.
7 Replies
8 months ago
package.json
{
"name": "seating-site",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"start": "vite preview --port 80"
},
"dependencies": {
"axios": "^1.7.5",
"serve": "^14.2.3",
"vue": "^3.4.29",
"vue-router": "^4.4.3"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.5",
"vite": "^5.3.1",
"vite-plugin-svg-icons": "^0.1.0"
}
}
railway.json
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS"
},
"deploy": {
"runtime": "V2",
"numReplicas": 1,
"startCommand": "npm run start",
"sleepApplication": false,
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
8 months ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open brody • 8 months ago
8 months ago
Hello, you are trying to run a development server.
here is a working vue template - https://github.com/brody192/vue-3-template
Copy the nixpacks.toml and Caddyfile into your project.
If you have a start command set in your service settings or railway.json remove it.
8 months ago
Hi brody,
it doesn't work. I copied the nixpacks.toml and Caddyfile into the root of the project. I have modified package.json, "server": "vite preview", as the default run comment is "serve". It still successfully deployed but got the below error
Failed to load resource: the server responded with a status of 502 ()
please help.
package.json
{
"name": "seating-site",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"serve": "vite preview"
},
"engines": {
"node": "18"
},
"dependencies": {
"axios": "^1.7.5",
"serve": "^14.2.3",
"vue": "^3.4.27",
"vue-router": "^4.4.3"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.5",
"vite": "^5.2.13",
"vite-plugin-svg-icons": "^0.1.0"
}
}
8 months ago
If i follow the package.json in https://github.com/brody192/vue-3-template
{
"name": "seating-site",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"engines": {
"node": "18"
},
"dependencies": {
"axios": "^1.7.5",
"serve": "^14.2.3",
"vue": "^3.4.27",
"vue-router": "^4.4.3"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.5",
"vite": "^5.2.13",
"vite-plugin-svg-icons": "^0.1.0"
}
}
then I can't even deploy it, below is the deploy log.
npm WARN config production Use --omit=dev
instead.
npm ERR! Missing script: "serve"
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR! npm run
8 months ago
Per my previous message -
> If you have a start command set in your service settings or railway.json remove it.
8 months ago
Per my previous message -
> If you have a start command set in your service settings or railway.json remove it.
Please refer to my previous message, if I remove the start command, railway will use the serve command in default, which will get the error above. Please help
8 months ago
Unless you've misconfigured something else, no Railway will not, the start command specified in the nixpacks.toml file will be used.
So please remove any start commands you have set in the service settings or anywhere else that isn't a nixpacks.toml file.