Forum in maintenance, we will back soon 🙂
Passing my App API Key to Heroku
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.
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 by: @adminSecond, 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: @adminif 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
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.
@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
@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=
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 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