Trouble with private network
mparisi76
HOBBYOP

a year ago

Hello! I am happy to have my app finally working now thanks to the awesome community!

I'm running into an issue with setting up my server url for front end app. I'm using the following:

BACKEND_URL="http://${{backend.RAILWAY_PRIVATE_DOMAIN}}:${{backend.PORT}}"

where backend is the name of my back end service.

When running the app in a browser, I get "http://:" for BACKEND_URL

What's the best way to troubleshoot this?

9 Replies

mparisi76
HOBBYOP

a year ago

eff4fdbb-16e0-4ffb-bee2-4ad13f2f307e


mparisi76
HOBBYOP

a year ago

env object from vite.config.mtd:{ VITE_MEDUSA_BACKEND_URL: 'http://:';, VITE_DISABLE_SELLERS_REGISTRATION: 'false', VITE_MEDUSA_BASE: '/' }


mparisi76
HOBBYOP

a year ago

Also, with private networking, how do I avoid the mixed content when the private (backend) url is http, and the front end is served over https? Browser will block this as mixed content.


a year ago

Vite is a client side web dev framework, so your environment variables will not work. This is because your code runs in the browser, rather than on your server.


a year ago

The Railway server serves the required files, but the browser actually runs them to display the website. Because the client browser doesn't have a BACKEND_URL variable, it won't be able to communicate with your backend


a year ago

You should just be setting your BACKEND_URL variable to your backend URL in code rather than relying on environment variables when using client-side apps


mparisi76
HOBBYOP

a year ago

This is not my repo - it's Mercurjs.. Somehow they had everything set up so it would work this way.. Will have to see if I Can figure out what they did differently


a year ago

it should be a pretty simple fix. Wherever BACKEND_URL is defined as os.getenv() or whatever the js equivalent is, just change that to the string value of the BACKEND_URL environment variable


mparisi76
HOBBYOP

a year ago

yep, thanks!


Welcome!

Sign in to your Railway account to join the conversation.

Loading...