I am trying to make file upload app with containerized React & Node.js. I got stuck with the error when I try to upload file. The developer console says like this on the VPS server.
POST http://localhost:4000/api/upload_file net::ERR_BLOCKED_BY_CLIENT
I built Node.js docker container at http://localhost:4000 and accepts post request to the route /api/upload_file and React container at http://localhost:3000 which accepts get request to the frontend.
My frontend javascript file related to fetch is here.
const TARGET = process.env.TARGET || 'localhost:4000'
export default async function uploadFile(formData) {
const fetchedData = await fetch(`http://${TARGET}/api/upload_file`, {
method: 'POST',
body: formData
})
.then((response) => {
if (response.ok) {
return response.json()
} else {
throw new Error('Something went wrong')
}
})
.then(res => {
return {
filename: res?.filename
}
})
.catch((error) => {
console.log(error)
})
return fetchedData
}
I searched for the solutions, but it seems browser's adblocker causes the error... I tried Chrome, Firefox and Brave, and had the same results.