Fetch same URL in Glitch

I’m unable to make this request

socket.on("newMessageClient", (message) => {
    fetch("https://fifth-large-bonsai.glitch.me/api/messages", {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
      },
      body: JSON.stringify(message),
    })
      .then((res) => {
      console.log(res);
      return res.json();
    })
      .then((data) => {
        if (data.error) return socket.emit("errorServer", data.error);

        io.emit("messageCreatedServer", data.messageCreated);
      })
      .catch((err) => {
        console.log(err);
      });
  });

res return this:

[Symbol(Response internals)]: {
type: 'default',
url: 'https://fifth-large-bonsai.glitch.me/api/products/657e18744bb20715b0ccec0b',
status: 403,
statusText: 'Forbidden',
headers: {
connection: 'close',
'content-length': '118',
'content-type': 'text/html',
date: 'Sat, 16 Dec 2023 21:44:27 GMT',
server: 'awselb/2.0'
},

could you try setting an User-Agent request header, they block requests that don’t have one

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