Trouble with private network
mparisi76
HOBBYOP

9 months 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

9 months ago

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


mparisi76
HOBBYOP

9 months ago

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


mparisi76
HOBBYOP

9 months 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.


9 months 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.


9 months 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


9 months 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

9 months 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


9 months ago

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


mparisi76
HOBBYOP

9 months ago

yep, thanks!


Loading...