Perform HTTP request on backend to retrieve secure endpoint location

This commit is contained in:
2024-08-18 16:56:05 +02:00
parent 59ba55793e
commit 3867a38ff9
5 changed files with 201 additions and 5 deletions

View File

@ -1,11 +1,22 @@
#include "unsecure_api.h"
#include "constants.h"
#include "esp_http_client.h"
#include "http_client.h"
#include "esp_log.h"
#include <string.h>
static const char *TAG = "unsecure_api";
char *unsecure_api_get_secure_origin()
{
const char *url = BACKEND_UNSECURE_URL "/secure_origin";
return strdup(url);
http_request_opts opts = {.url = url};
char *res = http_client_exec(&opts);
if (!res)
{
ESP_LOGE(TAG, "Failed to query api secure origin!");
return NULL;
}
return res;
}