R
Railwayβ€’4mo ago
CookieMonzteh

Help understanding how to connect domains

Hey yall. Im currently having trouble understanding how to get my railways apps domain. It seems a bit unclear to me. My project is backend and its just for mysql and im trying to connect my backend url to the front end however I dont know exactly what information to use. I go to my settings and check the public network however I dont know what exactly im supposed to do with it. If i copy and past it nothing happens and I get errors. Help explaining this to a fresher would be heavily appreciated. πŸ‘
No description
Solution:
why are you modifying the environment variables of the mysql database? you typically leave everything about mysql untouched, then create a new service where you deploy your code...
Jump to solution
21 Replies
Percy
Percyβ€’4mo ago
Project ID: N/A
CookieMonzteh
CookieMonztehβ€’4mo ago
N/A not sure where id even find project id
Brody
Brodyβ€’4mo ago
go to the service settings of your backend service and generate a domain
CookieMonzteh
CookieMonztehβ€’4mo ago
Did that, however when I do that and go back to my environment variable for some reason generating a domain removes port and host
CookieMonzteh
CookieMonztehβ€’4mo ago
No description
CookieMonzteh
CookieMonztehβ€’4mo ago
which im assuming I need for this no?
// Railway
export const sequelize = new Sequelize("railway", "root", process.env.MYSQLPASSWORD, {
dialect: "mysql",
port: process.env.MYSQLPORT,
host: process.env.MYSQLHOST,
define: {
freezeTableName: true,
timestamps: false,
},
});
// Railway
export const sequelize = new Sequelize("railway", "root", process.env.MYSQLPASSWORD, {
dialect: "mysql",
port: process.env.MYSQLPORT,
host: process.env.MYSQLHOST,
define: {
freezeTableName: true,
timestamps: false,
},
});
Brody
Brodyβ€’4mo ago
please send uncropped screenshots
CookieMonzteh
CookieMonztehβ€’4mo ago
not sure what that means? you mean fuller like this?
CookieMonzteh
CookieMonztehβ€’4mo ago
No description
CookieMonzteh
CookieMonztehβ€’4mo ago
im not sure why those 2 variable specificlly get turned into an empty string after generating a domain but am i supposed to just make the port 3306 and themsqlhost the domain url that was generated or do something else?
Solution
Brody
Brodyβ€’4mo ago
why are you modifying the environment variables of the mysql database? you typically leave everything about mysql untouched, then create a new service where you deploy your code
CookieMonzteh
CookieMonztehβ€’4mo ago
I havent, thats what im saying. after I generate a domain they change. This is like the 5th time ive restarted trying to do this. Im kinda new to this whole hosting thing So I dont understand that much. I just know I need to connect the environment variables given to me by railway in my code snippet I showed above, and then add my other backend variables to railway. My main problem has been trying to get a connection to my backend with the domain url. So im just using one container for mysql, and I have netlify running my front end
Brody
Brodyβ€’4mo ago
thats not your backend though, thats the database, you should not be modifying anything about it
CookieMonzteh
CookieMonztehβ€’4mo ago
oh? so you have to make a db and then another container for the backend code?
Brody
Brodyβ€’4mo ago
yes correct
CookieMonzteh
CookieMonztehβ€’4mo ago
that explains alot lol lawd
Brody
Brodyβ€’4mo ago
but you have for sure broken that database beyond reasonable repair by now, so best to delete it and make a new one, and then also make an empty service for your code (in the same project)
CookieMonzteh
CookieMonztehβ€’4mo ago
so wonder it wasnt working, I was trying to use a domain to connect to a database ffs πŸ’€ are there not docs that go over this very thing that im missing? I feel like I remember doing this but i thought that was because i ran my frontend on there and thats why i had 2 containers
Brody
Brodyβ€’4mo ago
well yeah thats one of the issues if you run a frontend, backend, and database on railway you would need 3 services total
CookieMonzteh
CookieMonztehβ€’4mo ago
Yeah my slow self thought you could do the db and backend in one but yeah no that makes sense should put me on the right track, ill post again if something comes up. thank you @Brody πŸ™
Brody
Brodyβ€’4mo ago
no problem!