Expose only one of two services

I have two services in Railway, back-end and front-end. I want only front-end to be exposed publicly, that is, back-end shouldn't be able to be called from any origin other than front-end. Is there a way to achieve this?
Solution:
if you want to do what you are asking, you would need a server side rendered app, where the server makes an internal request to the backend api, renders the page with data and returns the fully rendered page to the user
Jump to solution
18 Replies
Percy
Percy17mo ago
Project ID: 499c211e-ee48-4f8d-9cbf-b5569a601a8d
wisentini
wisentiniOP17mo ago
499c211e-ee48-4f8d-9cbf-b5569a601a8d
Brody
Brody17mo ago
no, the frontend would need a publicly available domain to call for data
wisentini
wisentiniOP17mo ago
but isn't the two services hosted on the same "environment"? like, isn't front-end local to back-end and vice-versa? if not, how can I achieve that besides Railway?
Brody
Brody17mo ago
is frontend a web app?
wisentini
wisentiniOP17mo ago
yep
Brody
Brody17mo ago
next?
wisentini
wisentiniOP17mo ago
angular
Brody
Brody17mo ago
is it a CSR app?
wisentini
wisentiniOP17mo ago
no, I need node
Brody
Brody17mo ago
so SSR?
wisentini
wisentiniOP17mo ago
no, sorry, it is CSR
Brody
Brody17mo ago
then the backend needs to have a public url for the frontend to call since the api call from the frontend will be made by the user not from within railway
wisentini
wisentiniOP17mo ago
ohhh, that makes sense
Solution
Brody
Brody17mo ago
if you want to do what you are asking, you would need a server side rendered app, where the server makes an internal request to the backend api, renders the page with data and returns the fully rendered page to the user
wisentini
wisentiniOP17mo ago
got it thanks again, @Brody
Brody
Brody17mo ago
any other questions?
wisentini
wisentiniOP17mo ago
nope!
Want results from more Discord servers?
Add your server