phpaxiosvuejs3http-status-code-502

Getting 502 on Vue3 with Axios


I try to send an axios request via

submitForm(){
      axios.post(process.env.VUE_APP_BASEURL+'/api/auth/signinout.php',{usern:this.usern,passw:this.passw})
      .then(res=> {
          console.log(res.data);
        })
        .catch((error) => {
          console.log(error.response);
        }).finally(()=>{

        });

and end up with a 502 Bad Gateway on localhost. The PHP file is nothing more than:

<?php
header('Content-type: application/json');
//phpinfo();error_reporting(E_ALL);
ini_set("display_errors", 0);

$json = file_get_contents('php://input');
// For illustration on what I also tried to do ...
//$json = $_POST{"usern"];
$answer = '{"messages":['.$json.']}';
  echo $answer;
 ?>

I simply want to replay the data sent via a form to a PHP script.

Thank you in advance.


Solution

  • The issue wasn't in the source code, but in the configuration of NGINX. Basically php-fpm hadn't worked out as it should (Arch issue) and then there was also the issue of putting the location ~.php entry under root / as well because otherwise a 404 error was produced.