Summary
Code: FUNCTION_INVOCATION_TIMEOUT
I am using NextJS as frontend service and ExpressJS as backend service. I am using getServerSideProps
for SSR in some of my pages. For the cors issue on production, I am setting proxy while calling the backend service.
So, I have configured next.config.mjs
file like below
async rewrites() {
return [
{
source: "/api/:path*",
destination: `${process.env.NEXT_PUBLIC_EXTERNAL_API}/:path*`,
},
];
},
I have deployed my nextjs app on vercel. It was running well a few days back. But now while hitting the page I am getting 504: GATEWAY_TIMEOUT, Code: FUNCTION_INVOCATION_TIMEOUT
.
Note: I am not getting the above error in the pages where I am not using getServerSideProps
.
Need some help on this!
Additional information
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
images: {
domains: ['test.s3.ap-south-1.amazonaws.com', 'via.placeholder.com'],
},
async redirects() {
return [
{
source: '/',
destination: '/upcoming',
permanent: false
},
]
},
async headers() {
return [
{
source: '/(.*)', // Matches all routes
headers: [
{
key: 'Access-Control-Allow-Credentials',
value: 'true',
},
{
key: 'Access-Control-Allow-Origin',
value: '*', // You can also restrict this to specific origins
},
{
key: 'Access-Control-Allow-Methods',
value: 'GET,OPTIONS,PATCH,DELETE,POST,PUT',
},
{
key: 'Access-Control-Allow-Headers',
value: 'X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version, Authorization',
},
{
key: 'X-DNS-Prefetch-Control',
value: 'on'
},
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN'
}
],
},
];
},
async rewrites() {
return [
{
source: "/api/:path*",
destination: `${process.env.NEXT_PUBLIC_EXTERNAL_API}/:path*`,
},
];
},
}
export default nextConfig;
I tried Changing next.config.mjs configurations and it did not work.