v0.1.3 - Implement https

This commit is contained in:
Your Name
2025-11-09 19:57:45 -04:00
parent e43dd5c64f
commit 30e4408b28
5 changed files with 18 additions and 7 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -45,13 +45,23 @@ int nip94_get_origin(char* out, size_t out_size) {
return 0;
}
// Check if request came over HTTPS (nginx sets HTTPS=on for SSL requests)
const char* https_env = getenv("HTTPS");
if (https_env && strcmp(https_env, "on") == 0) {
// HTTPS request - use HTTPS origin
strncpy(out, "https://localhost:9443", out_size - 1);
out[out_size - 1] = '\0';
return 1;
}
// HTTP request - check database config first, then use HTTP origin
sqlite3* db;
sqlite3_stmt* stmt;
int rc;
rc = sqlite3_open_v2(DB_PATH, &db, SQLITE_OPEN_READONLY, NULL);
if (rc) {
// Default on DB error
// Default on DB error - use HTTP
strncpy(out, "http://localhost:9001", out_size - 1);
out[out_size - 1] = '\0';
return 1;
@@ -76,7 +86,7 @@ int nip94_get_origin(char* out, size_t out_size) {
sqlite3_close(db);
// Default fallback
// Default fallback - HTTP
strncpy(out, "http://localhost:9001", out_size - 1);
out[out_size - 1] = '\0';
return 1;

1
test_file.txt Normal file
View File

@@ -0,0 +1 @@
test file content