Axios (node server) private network
If my private network name is "exotic-auth", how can I do a Axios request to it via private network.
The http client is setup like this:
for API_URL I've tried http://exotic-auth/v1 and exotic-auth/v1 but nether resolve.
Solution:Jump to solution
fiber runs on tcp4 by default, and the private network is ipv6 only, so
tcp
tells fiber to bind to both tcp4 and tcp6 (ipv4, ipv6)36 Replies
Project ID:
dd3f96f7-3ab3-4453-86a3-32328b2f81d6
dd3f96f7-3ab3-4453-86a3-32328b2f81d6
what port does it listen on?
i guess whichever $PORT is set by railway right?
but it's a web server via REST
its accessible on its public URL over https://
you can think of the private network like a lan, if you wanted to access an http service on another device on the lan, you would need to use a port in your url in that scenario, this is the same for railway private network, you need to use a port when connecting to other services in the private network
i see i see
so I should specify the port in the uri
indeed
ok big brain question here, can I use port 80 ? š
im guessing not, it's probably assigned a random port right
I can't recommend you listen on a privileged port
if it is indeed listening on railways random PORT, simply set a fixed PORT service variable and use that same port when making requests to the service across the private network
booom!
right
that'll solve it
lemme do that
ok weirdly
baseURL: 'exotic-auth:3000/v1',
AxiosError: Unsupported protocol exotic-auth:
i'm guessing i need to use http://exotic-auth:3000/v
1
yes use http, and use the full domain name instead for good measure
right
oof if this works
gonna be so good
i imagine even faster
and zero networking costs as long as communication is done exclusively over the private network
yeah
mostly doing this because damn Cloudflare is acting up though
reliability + speed
lmao you'll have that when an entire core data center drops offline
getting
AxiosError: connect ECONNREFUSED fd12:34a7:645b::a3:de4:3b2a:3000
on
Going to try the full internal name
exotic-auth.railway.internal
are you sure your exotic thingy is running on port 3000?
http://exotic-auth.railway.internal:3000/v1
yes one sec
ah I see the problem, let me consult the fiber docs
oh
in fiber.Config set
Network
to tcp
right
Solution
fiber runs on tcp4 by default, and the private network is ipv6 only, so
tcp
tells fiber to bind to both tcp4 and tcp6 (ipv4, ipv6)O.O
i have no idea how you work that out brody ^.^
I read the fiber docs so I know about this specific thing, I just had to check back for the correct config name
yeah š
works.
damn
pretty cool
pog
fr this must also add some speed...
i think pretty much everything is communicating by private network now
doesn't need to loopback around on the edge, yeah
side question but do you think railway webhooks can also resolve on the private network lol
i'm gonna test it
but this would be nice, since then I can verify the webhook came from railway also
nope it can't
ahh fair.
you could verify by cidr range maybe
i might add that as feedback, usually webhooks contain a HMAC or some means to verify the sender
but since it's railway, i figured a private network thingy might do it also
or some special header
see what headers they do set, maybe there will be something useful
true!