Hi,
my API was working in local using:
app.post('/api/v1/upload/', upload.array('image', 1), (req, res) => {
res.send({ image: req.file });
});
const PORT = process.env.PORT || 3000;
app.listen(3000, () => {
console.log(`server started on port 3000`);
});
when deployed to render:
app.post('/api/v1/upload/',upload.array('image', 1), (req, res) => {
res.send({ image: req.file });
});
const PORT = process.env.PORT|| 3000;
app.listen(PORT, () => {
console.log(`server started on port ${PORT}`);
});
in the local angular file I have
imageUpload(imageForm: FormData) {
console.log('image uploading');
return this.http.post('http://localhost:3000/api/v1/upload/', imageForm);
}
when deployed:
imageUpload(imageForm: FormData) {
console.log('image uploading');
return this.http.post('https://nodejs-20pl.onrender.com/api/v1/upload/', imageForm);
}
I am getting error 404 not found. why is that?