Database configuration
castanho
FREEOP

10 days ago

I'm trying to understand how to create a database an connect it to de site but i clearly don't know how to do this in a proper way.

I have the code in frontend but it cant connect with database. i tried many ways but i think i'll have to give up.

$10 Bounty

4 Replies

Railway
BOT

10 days ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


hey, when you spin up a database, and then you go to the variables tab, you should automatically see vars automatically created (such as the ones below).

to then hook them up to your frontend (go to your frontend service), you can directly add them via a variable. it'll dropdown with variables that you can add, and then select your database_url (or equivalent)

Railway has their own private networking (https://docs.railway.com/guides/private-networking), which is the difference between the database_url and database_public_url


yeeet

hey, when you spin up a database, and then you go to the variables tab, you should automatically see vars automatically created (such as the ones below).to then hook them up to your frontend (go to your frontend service), you can directly add them via a variable. it'll dropdown with variables that you can add, and then select your database_url (or equivalent)Railway has their own private networking (https://docs.railway.com/guides/private-networking), which is the difference between the database_url and database_public_url

castanho
FREEOP

10 days ago

I'll try that. thanks


Adding on to above, if you wish to connect to your database through frontend (which is highly not recommended), you should be using DATABASE_PUBLIC_URL.

However, I would recommend adding some sort of backend or at least a proxy to reduce vulnerabilities as well as reduce egress costs (Railway charges egress fees).


Loading...