R
Railway

✋|help

deploying react with vite

HDholy daddy9/18/2023
I've deployed a react app with vite, exposing network ip but I can't access it - says Application failed to respond on the url, i'm not sure what's wrong
HDholy daddy9/18/2023
6314f0f2-e1c1-471e-a5c2-4507a16c92b4 i am using "start": "tsc && vite --host 0.0.0.0 --port 3000" in package.json
BBrody9/18/2023
that starts a development server copy the nixpacks.toml and Caddyfile from this repo into yours https://github.com/brody192/vite-react-template
HDholy daddy9/18/2023
do i need to change any of the settings files
BBrody9/18/2023
just copy those two files
HDholy daddy9/18/2023
i did it but the logs still say
vite --host 0.0.0.0 --port 3000
VITE v4.4.9 ready in 375 ms
➜ Local: http://localhost:3000/
➜ Network: http:/...
vite --host 0.0.0.0 --port 3000
VITE v4.4.9 ready in 375 ms
➜ Local: http://localhost:3000/
➜ Network: http:/...
I had a Dockerfile but I renamed it, so now the build fails
BBrody9/18/2023
remove the dockerfile
HDholy daddy9/18/2023
I did
#16 0.309 /bin/bash: line 1: npm: command not found
#16 ERROR: process "/bin/bash -ol pipefail -c npm ci" did not complete successfully: exit code: 127
-----
> [stage-0 10/15] RUN --mount=type=cache,id=s/cfaf7ed2-171a-4cf4-8c6a-f175f50a42fd-/root/bun,target=/root/.bun npm ci:
0.309 /bin/bash: line 1: npm: command not found
-----

Dockerfile:26
-------------------
24 | ENV NIXPACKS_PATH /app/node_modules/.bin:$NIXPACKS_PATH
25 | COPY . /app/.
26 | >>> RUN --mount=type=cache,id=s/cfaf7ed2-171a-4cf4-8c6a-f175f50a42fd-/root/bun,target=/root/.bun npm ci
27 |
28 | # build phase
-------------------
ERROR: failed to solve: process "/bin/bash -ol pipefail -c npm ci" did not complete successfully: exit code: 127
#16 0.309 /bin/bash: line 1: npm: command not found
#16 ERROR: process "/bin/bash -ol pipefail -c npm ci" did not complete successfully: exit code: 127
-----
> [stage-0 10/15] RUN --mount=type=cache,id=s/cfaf7ed2-171a-4cf4-8c6a-f175f50a42fd-/root/bun,target=/root/.bun npm ci:
0.309 /bin/bash: line 1: npm: command not found
-----

Dockerfile:26
-------------------
24 | ENV NIXPACKS_PATH /app/node_modules/.bin:$NIXPACKS_PATH
25 | COPY . /app/.
26 | >>> RUN --mount=type=cache,id=s/cfaf7ed2-171a-4cf4-8c6a-f175f50a42fd-/root/bun,target=/root/.bun npm ci
27 |
28 | # build phase
-------------------
ERROR: failed to solve: process "/bin/bash -ol pipefail -c npm ci" did not complete successfully: exit code: 127
BBrody9/18/2023
can you share your repo?
HDholy daddy9/18/2023
all .env stuff is public but sure https://github.com/traagel/creditstar-fe
BBrody9/18/2023
🤣
No description
HDholy daddy9/18/2023
i've been up all night trying to finish this job application homework, its 9 am and i would like to sleep sadcat
BBrody9/18/2023
should have come here sooner https://test-service2.up.railway.app/ delete your bun.lockb file
HDholy daddy9/18/2023
damn you're a hero
BBrody9/18/2023
thanks 🙂
HDholy daddy9/18/2023
do you also know about flask deployment? i have the app.run(host="0.0.0.0", port=3000, debug=True) but it also says application failed to respond
BBrody9/18/2023
whats the python files name that has the flask app in it
BBrody9/18/2023
perfect your .env 😬
HDholy daddy9/18/2023
i know, i just wanted to get it working, it was supposed to be a 8 hour thing but now it's been like 3 days and i just want to get it done sadcat
BBrody9/18/2023
add this as a railway.json file
{
"$schema": "https://schema.up.railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS"
},
"deploy": {
"startCommand": "gunicorn main:app"
}
}
{
"$schema": "https://schema.up.railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS"
},
"deploy": {
"startCommand": "gunicorn main:app"
}
}
add this as a .gitignore file https://www.toptal.com/developers/gitignore/api/python delete the .env file from the repo delete the __pycache__ from the repo regen your database credentials from the settings menu of the database and we can pick this back up tomorrow on how to setup database credentials properly and for use locally too, without the use of .env anywhere forgot one thing, you will want to add gunicorn=21.2.0 to your requirements.txt file and i assume you didnt have the database variables in the railway service variables so your app is very likely to crash upon startup
HDholy daddy9/18/2023
packages/gunicorn/app/wsgiapp.py", line 58, in load
return self.load_wsgiapp()
File "/opt/venv/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
return util.import_app(self.app_uri)
File "/opt/venv/lib/python3.8/site-packages/gunicorn/util.py", line 371, in import_app
mod = importlib.import_module(module)
File "/root/.nix-profile/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 970, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'main.app'; 'main' is not a package
[2023-09-18 06:42:17 +0000] [9] [INFO] Worker exiting (pid: 9)
[2023-09-18 06:42:17 +0000] [1] [ERROR] Worker (pid:9) exited with code 3
[2023-09-18 06:42:17 +0000] [1] [ERROR] Shutting down: Master
[2023-09-18 06:42:17 +0000] [1] [ERROR] Reason: Worker failed to boot.
[2023-09-18 06:42:18 +0000] [1] [INFO] Starting gunicorn 21.2.0
[2023-09-18 06:42:18 +0000] [1] [INFO] Listening at: http://0.0.0.0:7314 (1)
[2023-09-18 06:42:18 +0000] [1] [INFO] Using worker: sync
[2023-09-18 06:42:18 +0000] [11] [INFO] Booting worker with pid: 11
packages/gunicorn/app/wsgiapp.py", line 58, in load
return self.load_wsgiapp()
File "/opt/venv/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
return util.import_app(self.app_uri)
File "/opt/venv/lib/python3.8/site-packages/gunicorn/util.py", line 371, in import_app
mod = importlib.import_module(module)
File "/root/.nix-profile/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 970, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'main.app'; 'main' is not a package
[2023-09-18 06:42:17 +0000] [9] [INFO] Worker exiting (pid: 9)
[2023-09-18 06:42:17 +0000] [1] [ERROR] Worker (pid:9) exited with code 3
[2023-09-18 06:42:17 +0000] [1] [ERROR] Shutting down: Master
[2023-09-18 06:42:17 +0000] [1] [ERROR] Reason: Worker failed to boot.
[2023-09-18 06:42:18 +0000] [1] [INFO] Starting gunicorn 21.2.0
[2023-09-18 06:42:18 +0000] [1] [INFO] Listening at: http://0.0.0.0:7314 (1)
[2023-09-18 06:42:18 +0000] [1] [INFO] Using worker: sync
[2023-09-18 06:42:18 +0000] [11] [INFO] Booting worker with pid: 11
this is the log atm
BBrody9/18/2023
kinda in the railway.json file it should be main:app not main.app my bad
HDholy daddy9/18/2023
BBrody9/18/2023
awsome!
HDholy daddy9/18/2023
One last thing, can you help me configure CORS? I already have it for python but i'm not sure how to do it for react i have it as CORS(app, resources={r"/api/*": {"origins": "*"}})
BBrody9/18/2023
that should allow all origins
HDholy daddy9/18/2023
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://creditstar-be-production.up.railway.app/api/v1/data/users/344-17-0576. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 200.
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://creditstar-be-production.up.railway.app/api/v1/data/users/344-17-0576. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 200.
BBrody9/18/2023
can you send me a link to where I would see this same error?
HDholy daddy9/18/2023
https://creditstar-fe-production.up.railway.app/ click on switch to sample user oh nvm it works now, maybe it didn't refresh
BBrody9/18/2023
I got a 404 on some unpaid_loans endpoint, but no cors errors
HDholy daddy9/18/2023
Ok great thank you so much, i can still submit it in time 😓 you really helped me out here
BBrody9/18/2023
no problem!

Looking for more? Join the community!

Want results from more Discord servers?
Add your server
Recommended Posts
OpenSSL error when using Bun + PrismaGetting an error when using Bun and prisma together. Prisma requires node to work, so start command Server isnt workingThe server suddenly stopped working. Could anyone explain what is going on?...How to deploy a project with multiple dockerfiles?Have project that has one `Dockerfile` for the backend service and another one `Dockerfile.celery` fWildcard DNS let user custom there domainI would like to know how to let's my users custom domain with CNAME to my domain DNS my DOMAIN CNABun with turborepo supportHey guys, Just switched over to bun from fastify but having some trouble setting it up properly to How does pro plan upgrade works for application? particularly Spring boot app...Hi all, I find it difficult to understand how pro plan upgrade works. I upgraded my Spring boot app Deploying Rust tries to copy binaries that don't exist.I'm not using my own nixpacks.toml, and railway is attempting to copy binaries that it doesn't need Cron skipingSo my Cron Schedule keeps skipping every time?Request to free up custom domainMy project id : 5df73bd5-7d04-40dd-9e57-97f1cdd89a60 Can u pls delete the given custom domain, it sPR PreviewsHi everyone. Is it possible to setup PR previews with it's own set of environment variables?Looking for way to run LibreTranslate as a service on railwayI'm looking for a way to run https://libretranslate.com on my railway instance. Ideally it would beRTT to nearby datacenter has gone way up in the past few daysRegions have been amazing and are super helpful for our use case. We host our database in AWS us-easPublishing .net 7 app - project file not foundHi, I'm new in railway and i'm faced with file structure problem. I heared that way to publish is sIssue with staging: The value needs to be expressed as a valid JSON string.i'm trying to make a dev and product env's, but now i created a service on the dev env and trying toIssue with staging: The value needs to be expressed as a valid JSON string.i'm trying to make a dev and product env's, but now i created a service on the dev env and trying toUse Volume with grafana will permission deniedI was configed volume and data path, but when i start my grafana, it will crash. This is log: Error:if i disconect an account of github ?whats going on with the repository are linking with this account ? fb928ae2-62f0-4f8f-be68-9f7902efCommunication between projects without requestsHey everyone, a question. Is it possible to establish communication between projects? For example, Ihow to setup webhooks?Hey guys I'm looking for how to setup a deploy webhook similar to vercel for my website with sanity.Template services in forked environment not deployingHi! When I create a new environment from the base one the two services, that I created from a templa