Hmmm. We couldn't reach this repl

Question: always “we couldn’t reach this repl” if we POST to the server, but if GET to the server, its work

This my code

const express = require("express");
const app = express();
const bodyParser = require("body-parser");
const { connect, Schema, model } = require("mongoose");
const { WebhookClient } = require("discord.js");
const { webhookUrl, mongoUrl } = process.env;
const { DateTime } = require("luxon");
const md5 = require("md5");

connect(mongoUrl)
  .then(() => {
    console.log("Connected To MongoDB");
  })
  .catch(console.error);

const sche1 = new Schema({
  owner: String,
  accessKey: String,
  serverId: {
    type: String,
    default: null,
  },
});

const auth = model("auth", sche1);

app.use(bodyParser.json());

app.get("/", (req, res) => res.send("Ready"));

app.get("/v1/serverid", async (req, res) => {
  const owner = req.query.owner;
  const accessKey = req.query.accessKey;
  const getServerId = await auth
    .findOne({
      $and: [
        {
          owner: owner,
          accessKey: accessKey,
        },
      ],
    })
    .then((res) => {
      return res?.serverId;
    })
    .catch(console.error);
  if (!getServerId)
    return res.status(401).json({
      status: "err",
      mess: "Wrong Owner ID Or accesKey",
    });
  return res.status(200).json({
    status: "success",
    mess: "Success Get ServerID",
    data: {
      serverId: getServerId,
    },
  });
});

app.post("/v1/auth", async (req, res) => {
  console.log(req)
  const body = req.body;
  const headers = req.headers;
  const owner = body.Owner;
  const accesKey = body.accessKey;
  const serverId = body.serverId;
  const authorization = headers.authorization.split("Bearer ")[1];
  const myAuth = md5(accessKey + owner);
  if (accessKey != myAuth) {
    return res.status(401).json({
      status: "err",
      mess: "Wrong Authorization",
    });
  } else {
    const webhook = new WebhookClient({ url: webhookUrl });
    const jakartaTime = DateTime.now().setZone("Asia/Jakarta");
    const formattedTime = jakartaTime.toFormat("yyyy-MM-dd HH:mm:ss");
    webhook.send({
      content: `<@${owner} execute script in ${serverId} at ${formattedTime}`,
    });
    return res.status(200).json({
      status: "Success",
      mess: "Success Auth",
    });
  }
});

app.listen(3000, () => console.log("Ready"));
1 Like
const cron = require('node-cron')
cron.schedule('0 12 * * *', async () => {
  const channel = await client.channels.fetch('1148058536325165121');
  channel.send('@everyone Good afternoon');

@Ghilan1 you there just asking?

i will help you with the set time thing that’s why i think it keeps telling you that but just saying it depends on the server time zone i think or for replit but be ready to delete some stuff but also your going to need a channel id