Skip to content

Forum in maintenance, we will back soon 🙂

Passing my App API ...
 
Notifications
Clear all

Passing my App API Key to Heroku

9 Posts
3 Users
2 Reactions
255 Views
Darren Jackson
(@darren-jackson)
Posts: 5
Active Member Customer Registered
Topic starter
 

I've built my first API app using Hasan's template. I have that app hosted and working on Heroku.

The problem I'm running into is I don't know how to pass my app's API key to Heroku from my website. I thought that I could use the Config Vars in Heroku, but I haven't had any luck.

The data from my WP site is getting sent to my app, but I'm getting a 404 error as a response due to the request not being authorized.

Any help would be appreciated.

 
Posted : 02/12/2024 3:25 am
Hasan Aboul Hasan
(@admin)
Posts: 1252
Member Admin
 

Hi friend, first congrats for publishing your API.

Second, why you wanna pass to Heroku, you pass to the API, the hosting platform has nothing to do with your API key.

if you are connecting with WordPress, my wp code snippets that I shared in the course already connects with an API key.

if you open your api directly in the browser and pass the key there, is it working normally?

 
Posted : 02/12/2024 11:51 am
Darren Jackson
(@darren-jackson)
Posts: 5
Active Member Customer Registered
Topic starter
 

Posted by: @admin

Second, why you wanna pass to Heroku, you pass to the API, the hosting platform has nothing to do with your API key.

This makes perfect sense and I'm not sure what I was thinking.

Posted by: @admin

if you open your api directly in the browser and pass the key there, is it working normally?

Yes. When I open the API online and enter the key, everything works great. But when I try from the site I get a 404 error in the Heroku log. The two log entries below are the same. The 200 OK entry is using the API directly in the cloud and the 404 is from my site.

My site is attempting to pass the data but it's being rejected.

2024-02-12T19:18:06.308772+00:00 app[web.1]: INFO: 70.95.135.126:0 - "GET /summarize?url= https://omeurl.html&length=5 HTTP/1.1" 200 OK

2024-02-12T19:16:21.241135+00:00 app[web.1]: INFO: 192.250.227.14:0 - "GET /summerize?url= https://omeurl.html&length=5  HTTP/1.1" 404 Not Found

 
Posted : 02/12/2024 7:25 pm
Darren Jackson
(@darren-jackson)
Posts: 5
Active Member Customer Registered
Topic starter
 

I'm doing a little more digging, and I don't think this is an API key issue after all. I think it has to do with how I need to pass the info to Heroku. I'll post again when I learn more or figure it out.

 
Posted : 02/12/2024 8:25 pm
SSAdvisor
(@ssadvisor)
Posts: 1139
Noble Member
 

@darren-jackson sounds to me as if your return endpoint isn't correct. Look at how you set up the return from the API.

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 02/12/2024 8:38 pm
Darren Jackson
(@darren-jackson)
Posts: 5
Active Member Customer Registered
Topic starter
 

@ssadvisor The first problem I found is that the two log entries from before aren't the same after all. It would really help if I could spell. Lol

"GET /summarize?url=
"GET /summerize?url=

 
Posted : 02/12/2024 8:44 pm
SSAdvisor reacted
Darren Jackson
(@darren-jackson)
Posts: 5
Active Member Customer Registered
Topic starter
 

I have this working now. Thanks for your suggestions. It turns out that I can't type/spell, and I made a mistake editing some code. I have my first working WP tool.

Thanks!

 
Posted : 02/12/2024 10:50 pm
SSAdvisor
(@ssadvisor)
Posts: 1139
Noble Member
 

Posted by: @darren-jackson

@ssadvisor The first problem I found is that the two log entries from before aren't the same after all. It would really help if I could spell. Lol

"GET /summarize?url=
"GET /summerize?url=

It happens to the best of us. VS Code has an extension (or several) for spell checking. You should add one so that you don't end up with accidental spelling issues.

 

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 02/13/2024 2:09 am
Hasan Aboul Hasan
(@admin)
Posts: 1252
Member Admin
 

@darren-jackson wow great, please share !

 
Posted : 02/13/2024 6:52 am
Share: