I have a frontend made of html, css and javascript, hosted in github pages, which when connected to public server, hosting the same backend code as my heroku app, works fine, so the problem must be in the backend. My heroku app deployed successfully, and contains:
heroku's php buildpack
Procfile with worker: php index.php $PORT
composer.json :
{
"require": {
"php": "^7.4.23"
}
}
a composer-generated composer.lock file (up to date)
the index.php code (which I dont think has any errors):
<?php
if($_POST['action'] == "approve")
{
$url = 'https://api.minepi.com/v2/payments/'.$_POST['paymentId'].'/approve';
$data = array();
}else if($_POST['action'] == "complete")
{
$url = 'https://api.minepi.com/v2/payments/'.$_POST['paymentId'].'/complete';
$data = array('txid' => $_POST['txid']);
}
$apps = array();
$apps['auth_app1'] = 'Key <api_key>';
$apps['auth_app2'] = 'Key <api_key>';
$apps['auth_app3'] = 'Key <api_key>';
$apps['auth_app4'] = 'Key <api_key>';
$ch = curl_init($url);
# Form data string
$postString = http_build_query($data, '', '&');
# Setting our options
$headers = array(
"Authorization: " . $apps[$_POST['client_URL']],
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
# Get the response
$response = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
header("HTTP/1.1 200 OK");
header('Content-Type: application/json');
echo json_encode($response);
?>
(I've omitted api_key and client_URL here)
Does anyone know what why this backend won't work? Thanks
UPDATE: The app now connects to the frontend but now shows this error when I use the app:
2021-09-12T20:21:36.181818+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=POST path="/" host=pi-webinars.herokuapp.com request_id=d5bac079-6bc7-4bbc-b5f7-18abab21c5d8 fwd="82.7.149.74" dyno= connect= service= status=503 bytes= protocol=https