Some of the server functions giving 500 - Internal server error


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.

This is my app. if you check the chrome console here, you will see request made to user is returning 500.

Hey there, @maverick :wave:

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.

Hey @hillary,

Thanks for looking into it. I have reproduced the same issue with different Netlify account. Here is the URL and screenshot:

Hey @hillary - The endpoints are working fine now. I am not exactly sure how :slight_smile:

1 Like

Thanks for letting us know! I am going to mark this issue as resolved for now. Let us know if it comes up again :slight_smile:

Hi @maverick ,

In the case you didn’t already realize, the function for ` is:

  "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

1 Like