[solved] Can't auth on Parse Server

Hi, Iā€™m struggling with parse server authentication
Iā€™ve downloaded Parse Server from Github, updated .env file with my data, install everything with npm install, followe instructions for build and run but I get errors on both browser console and termial

Uncaught ReferenceError: exports is not defined
at index.browser.cjs.js:3:23

POST http://localhost:1337/api/auth/sign-message 404 (Not Found)

Iā€™ve noticed the signon message on Metamask is always defi.finance. Could be this the problem? Where can I edit?

Thanks

you can also read this thread:

you will find that definition.finance in code and you can change it

if the error is that exports is not defined then I donā€™t know what is the fix

Thanks for your answer, but thereā€™s something I donā€™t understandā€¦
In the link you posted the code to Auth is

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

In parse-server Iā€™ve downloaded from github the code for auth is

const requestMessage = (account, networkType, chain) =>
  handleApiPost('request-message', {       /*'request-message'*/
    address: account,
    chain,
    networkType,
  });

const handleApiPost = async (endpoint, params) => {
  const result = await axios.post(`${AUTH_API_URL}/${endpoint}`, params, {
    headers: {
      'Content-Type': 'application/json',
    },
  });

  return result.data;
};

Iā€™d like to use v1 API to keep my old code

The ReferenceError was caused bu the solana js script in Index.html

you are referring to the front end code or to the backend code for auth?

The frontend one, in script.js

the code that you pasted here seems to be from the backend, what is the AUTH_API_URL?

Itā€™s the code in script.js, public folder of parse-server demo in your repository

This is the url

http://localhost:1337/api/auth/sign-message

and for some reason it canā€™t reach it

that is front end component then, the server has to run on port 1337, you can try to use 127.0.0.1 instead of localhost too, you can add some logging on the server side or look in the server logs to see if everything works as expected

Ok, now it works, I changed the expiration time like you told in the other post and the domain, Iā€™ve written wrong
Thanks for your support

1 Like