Issue with *Live Test* web calling an API

My app is tied closely to an API that is on a server (my desktop here at home) that is only accessible over http (not https)

Everything is working fine if I do live testing on my phone, but if I use Live Test web view, the webserver here doesn’t like the request, reporting:

2020-10-21 19:41:29 -0600: HTTP parse error, malformed request (): #<Puma::HttpParserError: Invalid HTTP format, parsing fails.>

My gut is this is because the thunkable.com Live Test is running on https, but that’s only a wild guess. Anyone else had this experience and know a workaround? Dev would be much quicker if I could use the on screen Live Test.

Thanks in advance

Keifer

I too had the same problem but I just live tested on a mobile phone and if you are using a laptop,
it won’t work at all and I had a self-experience on it

Yes. I can live test on the phone without an issue. Just not from the Live Test built in viewer at Thunkable.com. Not as efficient using a phone.

To connect a customizable API to thunkable web viewer in mobile you need to make sure about two things but that’s entirely up to you and how you’re building your API.

  • CORS
  • HTTPS requests.

Here is my tip on testing in Thunkable:

  • Do tests on your mobile Thunkable App (even though you’re not going for this platform, but you ca see if it works and do the proper adjustments to your API)
  • Do web testing by publishing the app as a mobile web app, you do need a PRO account (I haven’t tried it with responsive yet, but I imagine it might work too.)

Doing tests on just the web viewer preview you get on your projects is not going to work fully, so publish it first and see what works.

I deployed my API using Cloud Run in GCS, it gives you a https request API, you can code it in any programming language of your liking because you use docker :slight_smile:

And it’s pretty cheap :slight_smile:

There’s nothing wrong with the API, but possibly something incompatible with puma that’s serving it in the test environment over http. It works fine using Thunkable Mobile Live View, it would just be quicker if I could test with the Web Live View. I don’t really know much about CORS but I just tried running chrome with web security disabled which (I think) would get around this issue if it was CORS related, and I expect I would get a better error.

You say “HTTPS Requests”. Are you saying that you believe that the web preview cannot call an API on an http server? It’s hitting it, it’s just hitting it with an invalid HTTP format according to my logs.

Thanks

Keifer

If it’s hitting it, then try publishing it as a web mobile app and try it in ‘production’. :slight_smile: Just for better practices. I put a lot of labels you can see if it’s actually calling it correctly in Thunkable and start debugging it from there. That’s what I did and it worked, while I was debugging like this i found the CORS error just so you get a heads up haha

Hope this works for you. If not you can ask other community members :slight_smile:

I’m sure all that is true but what I’m trying to do is get the Live View working because that will make my development work flow faster.

I’m now 99% sure what is happening is that even if the API_URL is set to http:// live view web is calling it encrypting it so this is a thunkable live view issue, not an api issue.

Thanks

Keifer

Confirmed. Even if your API_URL is http:// thunkable live / web will call it over SSL so the only way to build / test an API and expect it to work on both web and phone is:

  • a local ssl certificate configured for your dev server (webrick / puma / thin / whatever)
  • API_URL to https:// and that actually resolving to your server without issues / warnings which is problematic in dev environments

Unfortunately I don’t know enough about certs to deal with the subsequent issues the phone comes up against… because the cert is a kludge.

If Thunkable peeps are here, I consider this a bug. If an API_URL is http:// then the call to it shouldn’t be over SSL… but maybe that’s impossible to change?

Bummer.

Keifer

Sounds like something that should probably be reported as a bug at https://github.com/thunkable/thunkable-issues/issues.

3 Likes