I have an app hosted in Heroku. It is divided in two apps, front (angular) and back (php), which communicate between each other. I needed a service that would host the database so the back can make petitions to obtain data, and I chose InfinityFree for that. In Heroku I have the environment variables declared with the values that I received when creating the database in Infinityfree, but all the petitions made time out and seems like there is no communication between both pages.
I’ve been doing a bit of research about it and I’ve found that, since Infinityfree is meant to host whole web pages and not just databases, it has some “security” system or whatever that prevents access to the database anywhere outside their domain. Is this true, or is it able to make a connection between both services?
It’s true that this is not possible here, but not because of the web browser validation system.
Instead, our database servers are simply not accessible from the internet. If you lookup the IP address for a database server, say sql310.epizy.com, you’ll see an IP address like 192.168.0.200. And the IP addresses starting with 192.168. are “internal” IP addresses, meaning they can be used in an internal network and are not routed over the internet.
If you check the network settings on your own computer, it probably has an IP address starting with 192.168. too, which is the IP address it has within your home network. But if you use an online IP checker tool, you’ll see that you’ll have a different IP to connect to the internet.
We won’t make our database accessible over the internet. We provide a website hosting service, not a database hosting service, and the databases we provide are intended to be used with our website hosting.
If you need to use a database at Heroku, last time I checked there was a commercial offering called JawsDB that offered a free tier. But you could also use a free Amazon RDS server with MySQL. All of that will be a lot better than some random web host’s database, because database connections are extremely sensitive to latency. And since Heroku hosts their stuff on Amazon, getting a database hosted on Amazon is highly recommended.
Although I did think about JawsDB, I discarded that option due to the small disk size that it provides for the DB. However, I didn’t know about Amazon servers, so thanks for the tip!
Currently I am trying uploading the back app here in Inifinityfree so it is able to make the petitions to the DB, and leaving the front app in Heroku. So far it looks like there is no problem, so as for now it might be a good solution.
Trying to find a good and free solution for this is making me crazy. I was going to try Amazon servers but seems like it’s not free and that’s not what I’m looking for (I’ve seen there is a free option but that’s like a trial version for 1 year).
So, before going to bed and call it a day, would I still be experiencing problems if I hosted the front-end here (which is made with Angular and I don’t even know if it could work here) so the connection between front-back-db would be all in this domain? Because if it is possible, I wouldn’t mind changing the front hosting service, but if it’s still going to be problematic then I guess I should try to think of anything else.
I don’t think it is possible. Infinityfree is only for web hosting and you cannot use it for API. Hence that is why you face to the browser check system when you try to fetch data from there.
Your only way is either to give a favor of your money pocket and pay for things or just look for free database hosting.
AngularJS is a frontend language. It runs entirely in the browser of the visitor. You don’t need Node.js on the server to run it.
For development, you’ll usually use a Node.js based server as well, so it can automatically recompile changes when editing the source code and reload the browser.
But in production, you don’t need the automatic reloading and a traditional web server like NGINX is far more efficient than using Node.js to serve the project.