Wrong url being called
koglersteve
HOBBYOP

a month ago

I am trying to get the frontend to connect with the backend. I ran the test one the backend and all the backend connections checked out good. I then moved to the fronted to connect to the backend. I set my frontend variable to call on the backend URL. When I load the page to test the connection I get os offline. I right click and check the network and the url the frontend os is calling on is the frontend URL.

What do I have backwards? What am I missing? I have gone over and over it and can’t figure it out. I enter one variable and it comes out the complete opposite.

Solved$10 Bounty

7 Replies

Status changed to Open Railway about 1 month ago


What URL is your frontend trying to reach to access your backend?


silasmuyembi0-cyber
HOBBY

a month ago

.railway.internal is internal-only browsers can't resolve it, only server-side services can.

Use your backend's public URL: https://your-backend.up.railway.app. On Vite, the variable must be prefixed with VITE_ or it gets stripped at build time.


koglersteve
HOBBYOP

a month ago

Thank you for the responses.

I am running Next.js set up the NEXT_PUBLIC_BACKEND_URL https://universal-core-backend-production.up.railway.app The URL being called is this one https://universal-core-frontend-production-8ae4.up.railway.app/os

I have done rebuilds, redeployed, deleted and reinstalled. I have looked for the cache history and cannot find that. I was told to erase the cache history. I make changes and every single time I keep getting the same frontend call. I do not get it.

Sorry total newb and getting frustrated.

I just tried this change BACKEND_URL https://universal-core-backend-production.up.railway.app and the frontend url was still called.

https://universal-core-frontend-production-8ae4.up.railway.app/os

This is the only thing keep getting

{ "message": "OS offline (no API)", "modules": [], "_api": null }


koglersteve
HOBBYOP

a month ago

 const API = getBackendUrl();
This is what I have. 

Can you try using console.log to make sure that your code is "eating" the environment variables?


koglersteve
HOBBYOP

a month ago

I tried the console.log. The NEXT_PUBLIC_BACKEND_URL only comes up as undefined. I cannot figure it out. As far as I can tell is the URL is not being accepted or recognized.

I keep testing all the other endpoints and those all check out.


koglersteve
HOBBYOP

a month ago

I would like to thank you all for your help and suggestions. They were helpful. I finally figured out the port was wrong. once I inputted the correct port I was connected. Thank you again.


Status changed to Solved Railway 29 days ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...