#Trouble with private network

9 messages · Page 1 of 1 (latest)

wind summit
#

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?

sturdy bluffBOT
#

Project ID: N/A

wind summit
#

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

#

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

radiant bobcat
#

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.

#

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

#

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

wind summit
#

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

radiant bobcat
#

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