tuxis-ie / nsedit

DNS Editor working with PowerDNS's new API
GNU General Public License v2.0
198 stars 55 forks source link

404 #178

Closed BoomerB closed 5 years ago

BoomerB commented 6 years ago

Hi,

I installed nsedit on Ubuntu 18.04 with Apache and php-fpm

I did: git clone https://github.com/tuxis-ie/nsedit.git cd nsedit/ git checkout tags/v1.1

I created a new domain. Now I wan to edit the SOA record and when I click Save I get an 404 error

PowerDNS logs show the following:

Jun 20 22:41:02 pdnsauth pdns_server[2917]: HTTP: Handling request "/api" Jun 20 22:41:02 pdnsauth pdns_server[2917]: HTTP: Result for "/api": 200, body length: 34 Jun 20 22:41:02 pdnsauth pdns_server[2917]: HTTP: Handling request "/api/v1/servers/localhost/zones/ltq.lab." Jun 20 22:41:02 pdnsauth pdns_server[2917]: gpgsql Connection successful. Connected to database '' on '/run/postgresql'. Jun 20 22:41:02 pdnsauth pdns_server[2917]: HTTP: Result for "/api/v1/servers/localhost/zones/ltq.lab.": 200, body length: 749 Jun 20 22:41:02 pdnsauth pdns_server[2917]: HTTP: Handling request "/api" Jun 20 22:41:02 pdnsauth pdns_server[2917]: HTTP: Result for "/api": 200, body length: 34 Jun 20 22:41:02 pdnsauth pdns_server[2917]: HTTP: Handling request "/api/v1/api/v1/servers/localhost/zones/ltq.lab." Jun 20 22:41:02 pdnsauth pdns_server[2917]: HTTP: No route found for "/api/v1/api/v1/servers/localhost/zones/ltq.lab." Jun 20 22:41:02 pdnsauth pdns_server[2917]: HTTP: Error result for "/api/v1/api/v1/servers/localhost/zones/ltq.lab.": 404

it looks like the prefix was applied twice

dnshs commented 6 years ago

In includes/class/PdnsApi.php

Remove localhost from

        $api->url = '/localhost/zones';
BoomerB commented 6 years ago

Hi, I did some debugging and the following hack solved the problem for me Kind Regards

ubuntu@nsedit:~/nsedit$ git diff
diff --git a/includes/class/ApiHandler.php b/includes/class/ApiHandler.php
index 15efef8..5b29acc 100644
--- a/includes/class/ApiHandler.php
+++ b/includes/class/ApiHandler.php
@@ -114,6 +114,12 @@ class ApiHandler {
     public function call() {
         if (substr($this->url, 0, 1) == '/') {
             $this->apiurl();
+           $l=strlen($this->apiurl);
+            if ($l > 0) {
+                if (substr($this->url, 0, $l) === $this->apiurl) {
+                    $this->apiurl='';
+                }
+            }
         } else {
             $this->apiurl = '/';
         }
@@ -121,4 +127,3 @@ class ApiHandler {
         $this->go();
     }
 }
-
ubuntu@nsedit:~/nsedit$ 
colbin8r commented 6 years ago

+1