I have deployed a Next JS webapp on netlify. There are a few server functions as well inside pages/api.
While some of the functions are working fine but some are giving 500 - internal server error. Even a simple hello world response is not working. I checked my code, all looks good.
I found a few solutions on netlify forums but none solved my issue.
Welcome to the Forums and thanks for reaching out! I followed your instructions and checked the chrome console. However, I am not seeing 500s, I am seeing 404s:
Can you share a different example of where you see the 500 internal errors? Additionally, can you share a repo and your most recent deploy log? This will help us look into this further.
{
"errorType": "Runtime.UserCodeSyntaxError",
"errorMessage": "SyntaxError: Cannot use import statement outside a module",
"trace": [
"Runtime.UserCodeSyntaxError: SyntaxError: Cannot use import statement outside a module",
" at _loadUserApp (/var/runtime/UserFunction.js:200:13)",
" at Object.module.exports.load (/var/runtime/UserFunction.js:242:17)",
" at Object.<anonymous> (/var/runtime/index.js:43:30)",
" at Module._compile (internal/modules/cjs/loader.js:1085:14)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)",
" at Module.load (internal/modules/cjs/loader.js:950:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:790:12)",
" at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)",
" at internal/main/run_main_module.js:17:47"
]
}
You can see this by hitting the endpoint for the lambda function.
Note: I’m making an assumption of your functions path (proxy), so ignore if it is incorrect