I read this issue several times in this forum but somehow it didnt solved my issue. So here it is:
I used some boilerplate for nextjs and moralis. Im using the code from here:
Here is my request-message.js
import Moralis from 'moralis';
const config = {
domain: process.env.APP_DOMAIN,
statement: 'Please sign this message to confirm your identity.',
uri: process.env.NEXTAUTH_URL,
timeout: 60,
};
export default async function handler(req, res) {
const { address, chain, network } = req.body;
await Moralis.start({ apiKey: process.env.MORALIS_API_KEY });
try {
const message = await Moralis.Auth.requestMessage({
address,
chain,
network,
...config,
});
const messageJson = JSON.stringify(message); // Convert message to JSON string
res.status(200).send(messageJson); // Send the JSON string in the response
} catch (error) {
const errorMessage = {
message: error.message,
stack: error.stack
};
res.status(400).json({ error: errorMessage });
console.error(error);
}
}
data:
{
address: '0xC408356F8C8fa0Ee64833c983C214Ea8A84E1c2d',
chain: 1,
network: 'evm'
}
{
domain: 'test',
statement: 'Please sign this message to confirm your identity.',
uri: 'http://localhost:3000',
timeout: 60
}
The error is following:
error - TypeError: Converting circular structure to JSON
--> starting at object with constructor 'TLSSocket'
| property 'parser' -> object with constructor 'HTTPParser'
--- property 'socket' closes the circle
at JSON.stringify (<anonymous>)
at sendJson (/Users/****/Documents/Privat/cs-homepage/node_modules/next/dist/server/api-utils/node.js:197:19)
at ServerResponse.apiRes.json (/Users/****/Documents/Privat/cs-homepage/node_modules/next/dist/server/api-utils/node.js:360:31)
at handler (webpack-internal:///(api)/./pages/api/auth/request-message.js:28:25)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Object.apiResolver (/Users/****/Documents/Privat/cs-homepage/node_modules/next/dist/server/api-utils/node.js:372:9)
at async DevServer.runApi (/Users/****/Documents/Privat/cs-homepage/node_modules/next/dist/server/next-server.js:513:9)
at async Object.fn (/Users/****/Documents/Privat/cs-homepage/node_modules/next/dist/server/next-server.js:815:35)
at async Router.execute (/Users/****/Documents/Privat/cs-homepage/node_modules/next/dist/server/router.js:243:32)
at async DevServer.runImpl (/Users/****/Documents/Privat/cs-homepage/node_modules/next/dist/server/base-server.js:432:29)
at async DevServer.run (/Users/****/Documents/Privat/cs-homepage/node_modules/next/dist/server/dev/next-dev-server.js:814:20)
at async DevServer.handleRequestImpl (/Users/****/Documents/Privat/cs-homepage/node_modules/next/dist/server/base-server.js:375:20)
at async /Users/****/Documents/Privat/cs-homepage/node_modules/next/dist/server/base-server.js:157:99 {
page: '/api/auth/request-message'
which in detail is following…
MoralisError [Moralis SDK Core Error]: [C0006] Request failed with status undefined: timeout of 10000ms exceeded
at RequestController.makeError (/Users/****/Documents/Privat/cs-homepage/node_modules/@moralisweb3/core/lib/controllers/RequestController.js:137:20)
at RequestController.<anonymous> (/Users/****/Documents/Privat/cs-homepage/node_modules/@moralisweb3/core/lib/controllers/RequestController.js:118:38)
at step (/Users/****/Documents/Privat/cs-homepage/node_modules/@moralisweb3/core/lib/controllers/RequestController.js:44:23)
at Object.throw (/Users/****/Documents/Privat/cs-homepage/node_modules/@moralisweb3/core/lib/controllers/RequestController.js:25:53)
at rejected (/Users/****/Documents/Privat/cs-homepage/node_modules/@moralisweb3/core/lib/controllers/RequestController.js:17:65)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
isMoralisError: true,
code: 'C0006',
details: {
status: undefined,
request: Writable {
_writableState: [WritableState],
_events: [Object: null prototype],
_eventsCount: 3,
_maxListeners: undefined,
_options: [Object],
_ended: true,
_ending: true,
_redirectCount: 0,
_redirects: [],
_requestBodyLength: 209,
_requestBodyBuffers: [Array],
_onNativeResponse: [Function (anonymous)],
_currentRequest: [ClientRequest],
_currentUrl: 'https://auth-api.do-prod-1.moralis.io/challenge/request/evm',
_timeout: null,
[Symbol(kCapture)]: false
},
response: undefined
}
}
The exact same code worked before. I did some changes to other pages of course … but didnt touched that code.
I hope someone can help me.
My API KEY is correct.
Im using localhost.