a year ago
Hi,
Context:
I have a monorepo with turborepo with two apps inside:
web (nextjs)
backend (node server)
I would like these two to communicate with each other over the private network.
I've read the docs and previous threads, but I am still not able to get it working.
My node server is listening on :: (to allowd IPv6) on port 3001.
In my web package I am fetching the following endpoint;
const baseUrl = env.NEXT_PUBLIC_BACKEND_BASE_URL;
const bookAxiosClient = axios.create({
baseURL: `${baseUrl}/books`,
});In my web service in Railway I've set the following env var:
NEXTPUBLICBACKENDBASEURL=http://${{Turbo repo BE.RAILWAYPRIVATEDOMAIN}}:3001/api
When i check the deployed frontend I see these errors (see attached screenshots)
Hopefully somebody can help me 🙂
Bert
31 Replies
a year ago
if the user's browser is making the api call (it is) then you need to use the public domain, it would not be a very private network if anyones browser could make a fetch call to a domain on the private network
Makes sense. Networking noob here 😦 Will try that and couple back to you.
a year ago
sounds good!
Mmm, still no success.
So what i did:
Changed the env var to the public name like this:
${{Turbo repo BE.RAILWAY_PUBLIC_DOMAIN}}/api
a year ago
you're calling the frontend domain
a year ago
I see fe there
Huh, how is that possible: i changed my env var to this ?
${{Turbo repo BE.RAILWAYPUBLICDOMAIN}}/api
a year ago
then you have to use that in code
a year ago
console logging time
https://turbo-repo-fe-production.up.railway.app/turborepo-production.up.railway.app/api/books
Seems like nextjs is interfering ? This is a 404 page of next itself.
a year ago
oh
a year ago
you forgot to add https:// to the variable in Railway
a year ago
nope, domain is a domain, not url
a year ago
also, it's better practice to not put /api there, do that in code
a year ago
no problem!
Must say this is 10/10 support. Even answering on a saturday 🙂 Thanks
a year ago
haha thank you
Just a follow up question: in my backend do i still need to bind it to :: now that I am using a public url ? I suppose this can be gone now ?
a year ago
you dont need to, but it doesn't hurt
a year ago
!s
Status changed to Solved brody • about 1 year ago




