Closed moonshotbaseball closed 1 month ago
The Ethers-operated CDN was deprecated 2 years ago (due to overwhelming costs) and was finally turned off yesterday.
The current recommendation for users is to use the amazing CDNJS service (it is completely free): https://cdnjs.com/libraries/ethers
From that link, you can access any version of Ethers you need. :)
(here is a direct link to the v5.2 you are using; I would also recommend upgrading to v6 as v5 is quite old)
What is the error?
Can you add a console.log to your handleApiPost
to see what is being returned? And try hitting your endpoint
directly to make sure it works?
Maybe you have a backend system that is offline or is also using the former Ethers-CDN scripts, and that no longer works now?
This line:
const { message } = await requestMessage(account, chain);
which is returning the message "Unauthorized" as a string, which calls this:
const requestMessage = (account, chain) =>
handleApiPost('{% url 'request_message' %}', {
address: account,
chain: chain,
network: 'evm',
});
Which calls this:
const handleApiPost = async (endpoint, params) => {
const result = await axios.post(`${endpoint}`, params, {
headers: {
'Content-Type': 'application/json',
"X-CSRFToken": '{{ csrf_token }}'
},
});
console.log({ result }); // <------ Add this line
return result.data;
};
I've indicated in the last code block which line you want to add, which will help you identify what your backend is returning. Maybe your CSRF token is invalid? But I'm pretty sure everything "blockchain" is working; it's the call to your endpoint that is returning the string "Unauthorized"
, I think. :)
Oh nevermind I just caught the issue was on my end as I had changed the Moralis API Key I was using at first because I thought maybe that was the issue, I just switched it back to the original and it seems to be working fine now, sorry about that!
Thanks so much for the quick help on this!
Glad you found it!
No worries! And happy hacking! :)
Ethers Version
5.2
Search Terms
No response
Describe the Problem
https://cdn.ethers.io/lib/ethers-5.2.umd.min.js returning an error in browser
Code Snippet
Contract ABI
No response
Errors
No response
Environment
No response
Environment (Other)
No response