My page import some module:
In getServerSideProps I get query and call api, then return response.
export async function getServerSideProps(context) {
try {
var startTime = Date.now();
const query = context.query;
const url = `myurl with query`;
const searchResulf = await axios.get(url);
var endTime = Date.now();
console.log(`Took ${endTime - startTime} milliseconds`);
return {
props: {
searchResulf: searchResulf.data,
},
};
} catch (error) {
console.error("error");
return {
props: {
searchResulf: null,
},
};
}};
In localhost everything is fine, never more than 2s waiting for api.
Took 939 milliseconds
Took 415 milliseconds
Took 840 milliseconds
In brower, never more than 5s for file HTML:
But when deploying on netlify (and vercel) this page is broken, other sites work properly. The function log get nothing, just "Error: Task timed out after 10.02 seconds".
I'm new to Nextjs, this is my first project, I'm stuck here for 2 days because of this error.