Self hosted server - auth ( vue app, v1 sdk)

hi all, we followed the self hosted server tutorial, we have an application built with v1 sdk
but many things are not working, starting from the Auth

in the server i see the error

warn: DeprecationWarning: auth.moralisEth is deprecated and will be removed in a future version. auth.moralisEth.enabled: true
error: Moralis auth failed, invalid data {“code”:101,“stack”:"Error: Moralis auth failed, invalid data\n at /Volumes/SSDInternal/Web3/PandolfiniNFT/server/build/auth/MoralisEthAdapter.js:33:15\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async Promise.all (index

and in the client console ( vue app )

i see

RESTController.js:302 POST http://localhost:1337/server/users 404 (Not Found)
dispatch2 @ RESTController.js:302
ajax @ RESTController.js:309
(anonimo) @ RESTController.js:416
Promise.then (asinc)
request @ RESTController.js:410
task @ ParseObject.js:3631
value @ TaskQueue.js:47
enqueueTask @ SingleInstanceStateController.js:289
save @ ParseObject.js:3644
(anonimo) @ ParseObject.js:2007
Promise.then (asinc)
value @ ParseObject.js:2006
value @ ParseUser.js:687
linkWith @ ParseUser.js:1760
value @ ParseUser.js:219
value @ ParseUser.js:1094
(anonimo) @ MoralisWeb3.js:688
tryCatch @ runtime.js:64
invoke @ runtime.js:299
(anonimo) @ runtime.js:124
asyncGeneratorStep @ asyncToGenerator.js:5
_next @ asyncToGenerator.js:27
Promise.then (asinc)
asyncGeneratorStep @ asyncToGenerator.js:15
_next @ asyncToGenerator.js:27
Promise.then (asinc)
asyncGeneratorStep @ asyncToGenerator.js:15
_next @ asyncToGenerator.js:27
Promise.then (asinc)
asyncGeneratorStep @ asyncToGenerator.js:15
_next @ asyncToGenerator.js:27
Promise.then (asinc)
asyncGeneratorStep @ asyncToGenerator.js:15
_next @ asyncToGenerator.js:27
(anonimo) @ asyncToGenerator.js:34
Wrapper @ export.js:18
(anonimo) @ asyncToGenerator.js:23
(anonimo) @ MoralisWeb3.js:724
loginWithMetamsk @ Login.vue:16
callWithErrorHandling @ runtime-core.esm-bundler.js:157
callWithAsyncErrorHandling @ runtime-core.esm-bundler.js:166
invoker @ runtime-dom.esm-bundler.js:345
Login.vue:23 Error: Moralis auth failed, invalid data
at handleError (RESTController.js:438:17)

where can i start to check the problem?
thank you

They changed the way that auth works with the self hosted servers (super annoying, I know). This is the code from the self hosted parse example they give: (here’s the github repo)

/**
   * 1) Connect to a Evm
   * 2) Request message to sign using the Moralis Auth Api of moralis (handled on server)
   * 3) Login via parse using the signed message (verification handled on server via Moralis Auth Api)
   */
  const handleAuth = async (provider: 'metamask' | 'walletconnect' | 'magicLink' | 'web3Auth' = 'metamask') => {
    try {
      setAuthError(null);
      setIsAuthenticating(true);

      // Enable web3 to get user address and chain
      await enableWeb3({ throwOnError: true, provider });
      const { account, chainId } = Moralis;

      if (!account) {
        throw new Error('Connecting to chain failed, as no connected account was found');
      }
      if (!chainId) {
        throw new Error('Connecting to chain failed, as no connected chain was found');
      }

      // Get message to sign from the auth api
      const { message } = await Moralis.Cloud.run('requestMessage', {
        address: account,
        chain: parseInt(chainId, 16),
        networkType: 'evm',
      });

      // Authenticate and login via parse
      await authenticate({
        signingMessage: message,
        throwOnError: true,
      });
    } catch (error) {
      setAuthError(error);
    } finally {
      setIsAuthenticating(false);
    }
  };

It’s working for me for metamask login, but still broken for MagicLink. Let me know if you make any progress with it.

1 Like