10 months ago
Hi folks
I have a seperate FE and BE service - two different projects.
The FE has an env var to locate the backend.
Should I set this to the internal URL of the BE service that railway exposes?
If so, should I prefix with http/https?
0 Replies
10 months ago
two different projects, or two different services?
please read this page so we can get our terminology correct before going forward -
10 months ago
thank you
10 months ago
is this a CSR frontend?
some of my build steps hit the backend, when I've changed to the internal URL (with https:// prefix) I get this:
```#12 22.31 TypeError: fetch failed
12 22.31 at node:internal/deps/undici/undici:12502:13
12 22.31 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
12 22.31 at async a (/app/.next/server/…/page.js:1:11099)
12 22.31 at async u (/app/.next/server/…/page.js:1:10740) {
12 22.31 digest: '4154157414',
12 22.31 [cause]: Error: getaddrinfo ENOTFOUND
12 22.31 at GetAddrInfoReqWrap.onlookupall as oncomplete
12 22.31 at GetAddrInfoReqWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
12 22.31 errno: -3008,
12 22.31 code: 'ENOTFOUND',
12 22.31 syscall: 'getaddrinfo',
12 22.31 hostname: '.railway.internal'
12 22.31 }```
10 months ago
the private network is not available during build time.
the internal domains may use domains instead of IP addresses, but they need to be treated like a local IP, meaning you use http and a port in the URL.
if your frontend calls the backend via SSR during runtime use the private network.
if a client's browser calls the backend, use the public url.
10 months ago
that is a pro only feature, and it doesnt have anything to do with private networking.
10 months ago
let me know if you have any more questions
sorry, one more, when addressing the internal url in SSR, do I use http or https prefix?
10 months ago
http
10 months ago
treat it like your local network, but instead of a ip, it uses a domain
thanks man. Is that something that's obvious to everyone but me, or should it be in docs? (Or, is it already?)
10 months ago
its not obvious to everyone, i can for sure see the logic in thinking you would use https with a domain name, but it is in the docs! -
10 months ago
its not always a first thought to dig into the docs, no worries!
ok - have been trying this, on an API call that is definitely SSR
I'm calling :8080/
from my frontend. My backend (python) has the internal url in ALLOWED_HOSTS
10 months ago
please provide the actual url you are using
10 months ago
<#727685388893945877> #5
10 months ago
I assure you it's not sensitive in the slightest
10 months ago
it wouldn't be a very private network otherwise haha
10 months ago
does your backend listen on 8080?
10 months ago
gunicorn? unicorn?
gunicorn - started with web: python [manage.py](manage.py) migrate && gunicorn .asgi:application -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:$PORT
10 months ago
remove the bind flag
10 months ago
(and it's accompanying host:port)
10 months ago
show me your new start command please
web: python manage.py migrate && gunicorn shareapodcast_be.asgi:application -k uvicorn.workers.UvicornWorker
10 months ago
what error are you getting now
10 months ago
very sorry, i was mistaken, your start command needs to be -
web: python manage.py migrate && gunicorn .asgi:application -k uvicorn.workers.UvicornWorker --bind [::]:$PORT
Next is now giving me warnings about mixed protocols being used (https vs http)
10 months ago
sounds good