Issue with API request on live

Good morning,

I am trying to get my project from localhost to be live on your servers, but seems that is impossible for some reason that now i think that i can’t do anything about it, i will try to explain:

I followed those steps here: https://github.com/netlify/next-on-netlify#installation
I also could simulate after install npm install -g netlify-cli and npm run build && netlify dev, all the routes works fine!

So localhost was working fine, I could simulate using your the command netlify dev, that opened a production environment on port 8888, everything works perfectly.

netlify.toml

[build]
  command   = "npm run build"
  functions = "out_functions"
  publish   = "out_publish"

  [dev]
    functions = "out_functions"
    publish   = "out_publish"
    framework = "#static"

Steps to get the issue

  • I just deployed using the git push command
  • I try to access the same route that i can access on localhost (localhost:8888/api/notes)
  • On live is strubloid.netlify.app, so I am trying to access strubloid.netlify.app/api/notes

Using postman

  • created a GET for the URL strubloid.netlify.app/api/notes
  • response: {“errorMessage”:“2020-09-22T13:18:00.962Z 6bec56c8-725c-4597-b1af-303822d6485d Task timed out after 10.01 seconds”}

Using the nextjs on my application

If you want to see how i am calling the API route, you can check this file:


Questions

  • Do we need to open any firewall rule on netifly?
  • Am I having this because i am not subscribed to the service paying the price?
  • Am I missing the port on the url strubloid.netlify.app to be able to get the API route?

Its been 3 days trying to get this to work, now its time to ask for help, I hope that someone can help me out!

Thank you!

How long is your function/API call supposed to take, to run? 10 seconds is where we’ll terminate your lambda if it is not finished running yet, so no surprise that you see things ending at that point. How fast does it run when you use netlify dev to access locally?

When examining our internal logs, I see a dozen attempts, and all timed out, so I guess the behavior is pretty steady and a fix should help all executions.

Hello Mate!

This ia a new aplication for studying purposes only, and until now I don’t have any large database in this specific application, so this request that I am talking about its to retrieve 2 notes, so I don’t think that time its the issue in this case.

On localhost, I build the fetch request using this URL: http://localhost:8888/api/notes, what should be on netifly? i think that I am getting https://strubloid.netlify.app/api/notes and its missing the port?

Thank you for reaching back!

No need for a port here - the default will work (it’ll be 443 since your browser will be speaking https here).

You should add in some more logs to understand why the function takes 10 seconds to run. I can see that we are at least trying to run it - not sure if successful or no - but it never finishes within 10 seconds.

Maybe try a hello world type function that you can be more sure of working in AWS just as a proof of concept to make sure that what you’re testing locally packs up and deploys reasonably? Right now we’re trying to debug two intertwined things:

  • does your function work
  • and is it timing out

Something simpler would let us separate those concerns. Many examples here so you don’t have to write your own if you don’t want :slight_smile: https://functions.netlify.com/examples/