'503 error when posting a file to a php server with node js and axios using formdata module

I am trying to send a file from my node js app to a PHP server where an opencart app is hosted. I am using formdata and axios modules to make the request and upload the file.

my issue is that I am getting this error Error: Request failed with status code 503

How to fix?

here is my code in node js:

let form = new FormData();
form.append("file", fs.createReadStream(path.resolve(zipFilePath)), path.basename(zipFilePath));

            try {
                let response = await axios.post(endpoint, form, {
                    headers: {
                        ...form.getHeaders(),
                    },
                });

                const result = response.data;
                if (result && result.status === "success") {
                    fs.unlinkSync(zipFilePath);
                }
            } catch (e) {
                console.log(e.toString());
            }

and php code (function in a controller):

public function upload() {
        header('Access-Control-Allow-Origin: *');
        
        if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
            $this->response->setOutput(json_encode([]));
        } else {
            // process the file posted
        }
    } 


Solution 1:[1]

The issue has been sorted out.

the problem was that the opencart app were set to maintenance mode in the backend, but frontend were still working normally so did not notice that earlier.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 anwar