I'm trying to send a file from my Node js application to a PHP server hosting an opencart application. I'm using formdata and axios modules to make requests and upload files.
My problem is that I get this error Error: Request failed with status code 503
How to solve?
This 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 controller):
public function upload() { header('Access-Control-Allow-Origin: *'); if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') { $this->response->setOutput(json_encode([])); } else { // process the file posted } }
problem solved.
The problem is that the opencart application is set to maintenance mode on the backend, but the frontend is still working normally, so it was not noticed before.