Moralis self hosted server auth fails with moralis version 2

I am trying to connect self hosted server in moralis version 2 but authentication is failed
also showing Error: Moralis auth failed, invalid data when i am using moralis-v1 or version 2

export async function startMoralis() {
  
  const serverUrl = "http://localhost:1337/server";
  const appId = "001";

  Moralis.start({ serverUrl, appId});
}

async function login() {
    let user = Moralis.User.current();
    if (!user) {
      user = await Moralis.authenticate({
        provider: wallet_name,
        signingMessage: "Log in using Moralis",
      })
        .then(async function (user) {
          user_address = user.get("ethAddress").substring(0, 6);

          const chainId = await Moralis.chainId;

          const accepted_chains = ["0x61", "0x38"];

          if (accepted_chains.includes(chainId)) {
            chain = chainId;
          } else {
            try {
              await Moralis.switchNetwork("0x38");
            } catch {
              alert(
                "Could not connect to Metamask. Please try switching chains."
              );
            }
          }

          // Subscribe to onChainChanged events
          const unsubscribe = Moralis.onChainChanged(async (chainId) => {
            if (accepted_chains.includes(chainId)) {
              chain = chainId;
            } else {
              try {
                await Moralis.switchNetwork("0x38");
              } catch {
                alert(
                  "Could not connect to Metamask. Please try switching chains."
                );
              }
            }
          });
        })
        .catch(function (error) {
          console.log(error);
        });
    }
  }

async function handleWalletClick() {
    let user = Moralis.User.current();
    if (!user) {
      await login();
    } else {
      await logOut();
      user_address = null;
    }
  }

  export async function initMoralis() {
    await Moralis.enableWeb3();

    user_address = Moralis.User.current().get("ethAddress").substring(0, 6);

    const chainId = await Moralis.chainId;

    const accepted_chains = ["0x61", "0x38"];

    if (accepted_chains.includes(chainId)) {
      chain = chainId;
    } else {
      try {
        await Moralis.switchNetwork("0x38");
      } catch {
        alert("Could not connect to Metamask. Please try switching chains.");
      }
    }

    // Subscribe to onChainChanged events
    const unsubscribe = Moralis.onChainChanged(async (chainId) => {
      const accepted_chains = ["0x61", "0x38"];

      if (accepted_chains.includes(chainId)) {
        chain = chainId;
      } else {
        try {
          await Moralis.switchNetwork("0x38");
        } catch {
          alert("Could not connect to Metamask. Please try switching chains.");
        }
      }
    });
  }

Hi @Ayush

This signing message is incorrect. The message should be taken from the requestMessage API endpoint.

This is how to get the message with self host server.

const { message } = await Moralis.Cloud.run("requestMessage", {
        address: account,
        chain: parseInt(chainId, 16),
        network: "evm",
      });

You can find the complete authentication example code in this docs

@johnversus i know but in docs they are authenticating with react-moralis and i am using svlete framework for frontend, so i am not getting any documentation to authenticate with self hosted server in svlete
so is there any way to authenticate with vanilla js or any other approach

The docs for old v1 sdk can be found here.

Also please check the reply on your other post.