I followed all the steps to setup an Inventree Production instance and it is running perfectly.
I also created an admin account after the installation, as suggested in the documentation.
However i ran into an issue when trying to communicate with Inventree from a Laravel application running on the same device and domain.
Every API Call i do towards Inventree gets returned as “Not Found” reasonPhrase and a statusCode of “404”.
IlluminateHttpClientResponse {#335 ▼ // appHttpControllersLoginController.php:32
#response: GuzzleHttpPsr7Response {#371 ▼
-reasonPhrase: "Not Found"
-statusCode: 404
-headers: array:4 [▶]
-headerNames: array:4 [▶]
-protocol: "1.1"
-stream: GuzzleHttpPsr7Stream {#367 ▶}
}
#decoded: null
+cookies: GuzzleHttpCookieCookieJar {#352 ▶}
+transferStats: GuzzleHttpTransferStats {#372 ▼
-request: GuzzleHttpPsr7Request {#358 ▼
-method: "GET"
-requestTarget: null
-uri: GuzzleHttpPsr7Uri {#354 ▼
-scheme: "http"
-userInfo: ""
-host: "localhost"
-port: null
-path: "/api/user/token/"
-query: ""
-fragment: ""
-composedComponents: "http://localhost/api/user/token/"
}
-headers: array:3 [▼
"User-Agent" => array:1 [▶]
"Authorization" => array:1 [▶]
"Host" => array:1 [▶]
]
-headerNames: array:3 [▶]
-protocol: "1.1"
-stream: GuzzleHttpPsr7Stream {#357 ▶}
}
-response: GuzzleHttpPsr7Response {#371 ▶}
-transferTime: 0.00125
-handlerStats: array:39 [▶]
-handlerErrorData: 0
}
}
I am trying to request an Inventree API Token from my Laravel application. The Laravel application is hosted at “http://localhost:8080”. In the .env file of Inventree, i’ve changed the INVENTREE_SITE_URL to “http://localhost”. Both applications are running fine.
From my laravel application I am trying to call this API:
$response = Http::withBasicAuth($username, $password)->get("http://localhost/api/user/token/");
I have checked multiple times that the credentials are correct and that the syntax of the API call is correct too, Ive copied it straight from the api-docs provided by Inventree.
In relevant log output, i have included the response from the API attempt.
When i attempt to call the API, i don’t get any output in the inventree docker container either. if my Laravel application is making a request to http://localhost/api/user/token/, it should be handled by Caddy and reverse proxied to the Inventree server container. But this does not seem to happen since there are no logs.
I am lost. Is there anything i’ve missed?