InfinityFree DB + Heroku?

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?

That is correct. Here is the article on the subject:

3 Likes

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.

3 Likes

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.

Thanks a lot!

If you do that you may run into the security system described by @Greenreader9. Separate frontend/backend hosting is not really something we support.

Yep, as the link says, I’ve been having some problems with CORS and the Access-Control-Allow-Origin header, so sadly I think I’m going to try Amazon servers or try to fix it somehow.

Thanks for everything though!

1 Like

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 believe that will work here. You can give it a shot though.

Try that. Sometimes sleeping on it helps. What you are looking for is a free database hosting provider

I’ve been told I might be able to do it by configuring a proxy in Angular so all petitions go to Heroku’s domain. Let’s say we have Herokus url (project-heroku.com) and Infinity’s (project-infinity.com). That way, in order to access the front we would go to project-heroku.com/login (for example), then when submitted, the pettition to the back would be project-heroku.com/api/login (having setted project-heroku.com/api to redirect to project-infinity.com). That way, all request are in the same domain.

Do you think it would be possible? Or would it be restricted due to the platform?

I am a bit confused, and not quite following. Please read this article to see if it says anything that might contradict your plan.
Thanks

I set up the proxy and looks like it redirects the petition correctly, but now it’s giving me the JavaScript error mentioned in the link. Isn’t there any way to fix this issue? Maybe it depends on the browser? I’m using Vivaldi, which us built in chromiun.

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.

1 Like

I think that will work here.

The main thing to note though is that we don’t provide command line access or Node.js on our servers. So you’ll need to build the frontend site somewhere else and then push it here over FTP.

The Angular site served from our servers can then talk to the PHP backend hosted with us, and use the database we provide to store the backend data.

I’m not going to lie to you: setup and deployment will probably be painful. But it’s possible and it’s free.

I mean, I’ve been trying to find a free solution for a while with no luck and it’s already being painful, so I don’t think I could lose anything for trying.

What I didn’t really understand was this:

So you’ll need to build the frontend site somewhere else and then push it here over FTP.

By that do you mean to build the project in production mode somwhere (maybe locally?) and upload the resulting files to the service? Wouldn’t it need a node.js server in order to run?

Correct.

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.

The only time you NEED Node.js is during the build step when you’re turning the AngularJS code (which tends to be a more convenient Typescript or ECMAscript) into HTML and Javascript that can be executed in most browsers. The tooling that does this conversion is all written in Javascript, which is where Node comes in.

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.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.