I have created a NEXT.js app calling from pages/api to get the data from moralisDB.
this is my code on api/index.js
import {Moralis} from 'moralis/node'
export default async function handler(req, res) {
const {method} = req;
const serverUrl = process.env.NEXT_PUBLIC_SERVER_URL;
const appId = process.env.NEXT_PUBLIC_APP_ID;
const moralisSecret = process.env.NEXT_MORALIS_SECRET;
// Initialize Moralis Server side
await Moralis.start({ serverUrl, appId, moralisSecret });
// offer collection
const tbOffer = Moralis.Object.extend(process.env.NEXT_OFFER_COLLECTION_NAME);
if (method ==='GET'){
try{
const query = new Moralis.Query(tbOffer);
const allOffers = await query.find();
res.status(200).json(allOffers);
console.log(allOffers);
} catch (err){
res.status(500).json(err)
}
}
}
I keep getting error response 500 with the response: Could not fetch keys with moralisSecret
It was working fine for a couple of days, and now it stopped.
I will appreciate any advice.
thanks