Fetch DELETE redirects to errors.infinityfree.net/403/

Username (e.g. epiz_XXX) or Website URL

http://tedisproject.infinityfreeapp.com/

Error Message

  1. Request Method: DELETE

  2. Status Code: 302 Found

  3. Remote Address: xxxxxx

  4. Referrer Policy: strict-origin-when-cross-origin

Other Information

Fetch DELETE works when I test my web app on localhost - it successfully deletes all selected products from my SQL database. But when I publish web app on infinityfree it redirects me to infinityfree error “403 Forbidden” when using Fetch DELETE. At the same time Fetch GET and POST works fine on infinityfree.

What can I do to enable Fetch DELETE?

My Fetch DELETE code is seen below:

async function sendDeleteRequest(i) {
const response = await fetch(Links[“products”], {
method: “DELETE”,
body: JSON.stringify(props.updatedProducts[i]),
headers: {
“Content-Type”: “application/json”,
},
});
const data = await response.text();
console.log(data);
navigate("/productlist");
}

See if it applies…

1 Like

I think all HTTP keywords other than GET and POST are blocked on our hosting. Most websites don’t use them, after all.

2 Likes

Then how can I send DELETE request to my SQL database?

Should I send from Front End using POST request data in which there is a key word that indicates that I want to DELETE something in the database and then Back End has to catch this key word and execute the DELETE query?

Yes, that’s as good a way as any to do it.

You can use GET or POST, and you could identify the intended action with a field in the payload, a different URL or even a custom request header.

6 Likes

Why most websites don’t use other HTTP keywords besides GET and POST?

Because those are generally used for API purposes, and because we are not an API host, it doesn’t make sense to support those methods.

5 Likes

What @wackyblackie said. And also because you cannot do other HTTP keywords without involving custom Javascript.

A POST or GET request can be made from a <form> HTML tag. A GET request is also performed when you open a URL from an <a> tag. But PUT/PATCH/DELETE cannot be done like that.

4 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.