For anyone else who has came across this error:
The issue is that when u deploy to production your sever hostname is different than your frontends hostname
This appears to be an issue within the authService.ts
file for self hosted parse server.
const result = await Moralis.Auth.requestMessage({
address,
chain,
networkType,
domain: "frontend.URL.hostname", //eg. 'example.com'
uri: url.toString(),
statement: STATEMENT,
notBefore: now.toISOString(),
expirationTime: expirationTime.toISOString(),
timeout: TIMEOUT,
});
hardcoding the value for domain will get rid of that error,
You could also do a more permanent fix by adding this to your .env
FRONTEND_URL="yourUrl"
Then, adding this to your `config.ts
FRONTEND_URL: str({
desc: 'Referenece to your frontend URL. Replace this when your frontend is deployed',
devDefault: `http://localhost:3000',
}),
and adjust ur authService.ts
accordingly
import Moralis from 'moralis';
import config from '../config';
export interface RequestMessage {
address: string;
chain: string;
networkType: string;
}
const STATEMENT = 'Please sign this message to confirm your identity.';
const EXPIRATION_TIME = 900000;
const TIMEOUT = 15;
export async function requestMessage({
address,
chain,
networkType,
}: {
address: string;
chain: string;
networkType: 'evm';
}) {
const serverURL = new URL(config.SERVER_URL);
const frontendURL = new URL(config.FRONTEND_URL);
const now = new Date();
const expirationTime = new Date(now.getTime() + EXPIRATION_TIME);
const result = await Moralis.Auth.requestMessage({
address,
chain,
networkType,
domain: frontendURL.hostname,
uri: serverURL.toString(),
statement: STATEMENT,
notBefore: now.toISOString(),
expirationTime: expirationTime.toISOString(),
timeout: TIMEOUT,
});
const { message } = result.toJSON();
return message;
}
``