Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
    Jeff Scott
    Nevermind :)
    Rainer Selvet
    Hey guys, is anyone aware if Netlify function executions are guarded by some kind of abuse control (Like AWS WAF)? Let’s say you deploy a public function accessible from site.com/api what would stop someone spamming that endpoint with thousands of requests and exceeding your plan limit? Just tried running Apache Benchmark against one of my functions on Netlify and running a couple thousand invokations in ~2 sec goes through.

    The issue with this is I think after the function goes to sleep the cached variable gets deleted, another issue is the first API Call takes a long time to finish. I'm also getting some errors while running this code

    (node:19101) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'statusCode' of undefined
        at callback (/home/sc/web-projects/ecomm/node_modules/netlify-lambda/lib/serve.js:35:42)
        at /home/sc/web-projects/ecomm/node_modules/netlify-lambda/lib/serve.js:68:7
        at processTicksAndRejections (internal/process/task_queues.js:93:5)
    UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)

    I don't why that is as i have provided try{} catch{} and then .catch methods.

    Can someone guide me to a better solution or critique me on how i can better implement what i am trying to achieve. Thank You.

    Gabor Gyarmati

    Hi Guys, I am receiving 502 on netlify even though it returns the content string. Anybody experienced this before?

    It returns my content in the error header, and returns "Http failure response for https://demos-portal.netlify.com/.netlify/functions/get-demos: 502 OK" in the message

    Does anyone know if Netlfiy functions work with Gatsby cloud, so far it works in Development Locally and In netlify build but get a 502 response on netlify cloud?
    Oh I think I didn;t put the env variables in gatsby cloud
    sorry a 504, still testing
    still getting a error now I get this
    Error occurred while trying to proxy request sendmail from riel-design-2611766185.gtsb.io to http://localhost:9000
    Dani Tulp
    @wispyco Have you figured this out by chance?
    Gatsby support told me they dont allow port 9000 to be used on gatsby cloud
    Marco Melilli
    Hi guys, i'm trying "Gatsby Builds" to build my site and hosting it on netlify. Do you know if there is a way to integrate netlify functions? After the build, if I try to reach the endpoint I receive a 404. If I build it with netlify it works well
    Nicolás Salvo
    Hi, i'm struggling with a nested function in typescript when trying to build. I'd made a script on package.json "postbuild": "netlify-lambda build src/functions". In src/functions there are 2 nested functions -> src/functions/hello-world/hello-world/ts && src/functions/node-fetch-node-fetch.ts. When building I got an error: "---Start netlify-lambda notification---
    WARNING: No valid single functions files (ending in .mjs, .js or .ts) were found.
    This could be because you have nested them in a folder.
    If this is expected (e.g. you have a zipped function built somewhere else), you may ignore this.
    ---End netlify-lambda notification---".
    If, for example, hello-world is not nested (src/funtions/hello-world.ts), then it's works and the function get build in the path chosen in the netlify.toml file. Thus also work the invoke function with netlify dev.
    I'm doing this because if i have a dependency with a function, i dont want to have in the main package.json, I want it inside my nested functions. Do you know how to proceed?
    Mike Mahon
    @NGSalvo_twitter include the zip in the lambda, you can add it in the ui
    Nicolás Salvo

    @jetstreamin what you mean to include the zip in the lambda? You mean to transpile the files and move the files? Maybe i'm not clear, sorry.
    The warning says that I could have my functions in nested folders which is true in my case. But i do not know what to do. Maybe is a thing with netlify-lambda or most probably with misconfiguration from me.
    By putting all my typescript functions in the same level (that means inside functions's folder) the files are transpiled to javascript and moved to the correct folder described in netlify.toml. But I want them to keep the structure that I want inside a folder with the same name as the function name, just like it's in the docs of netlify-dev.
    Working structure:

    What I desire:
    Because i want to have my functions with their own package.json
    The vanilla javascript functions works well with the folder structure that I desire.
    Thanks for the response!

    Mathias Bøe
    Hi guys, I'm pretty new to gatsby and netlify when it comes down to actually make a larger project in it. I am at the point where I need to use some API keys and have stored them in netlify. I need to access them though and have no idea where to start really. The keys can in theory be public, but I'd rather not share my API keys (its bad practise, but you know this). Anyway, I just need a pointer to know where I should start as I am currently in the dark here..
    Taliesin Beynon
    Hello all. Enjoying lambda functions in Netlfiy so far. Question: I have a function that is generating small amounts of data, and I'm looking for a service where I can POST JSON and have it appended to a big, dumb log, such that later I can just download it for analysis. I don't need querying or anything like that. Logging solutions like loggly and timber.io are great but they are expensive and they have limits on how long they'll keep the data. I just want something dumb and cheap. Any ideas?
    Jon Dujaka
    hey @taliesinb , I just came across the same need. I'm actually considering just writing to a google sheet.
    Or the other option is to use your CMS' content API and add it somewhere in there.
    Jon Dujaka
    @mrboen94 hey Mathias, what you're actually looking for is Enviroment variables. You can set these variables in the Netlify dashboard, and then access them in your code through process.env.VARIABLE_NAME.
    Xiaofeng Liao
    Hi All, I am new to netlify. I am trying to follow the example at https://github.com/elastic/search-ui/tree/master/examples/elasticsearch, which includes a Netlify Function to proxy with the Elasticsearch instance locally. I got an error saying: Failed to load resource: the server responded with a status of 500 (Internal Server Error) http://localhost:3000/.netlify/functions/search. I googled and didn't find much info similar to my settings. Could any one give a hint? Thank you all.
    Vegim Qehaja
    using netlify functions to call: firestore.collection("helloworld").doc('test').set({ data: 'test', }) makes the netlify function timeout when deployed any ideas?
    Alex Chiu
    Hi All, just joined to say I'm also experiencing some issue running Firebase Firestore queries like @gimi-q above. Also running a very simple query which works perfectly fine locally when running Netlify Dev, but when published I'm seeing the error 2020-07-05T16:37:05.769Z 2ed6bae0-3702-441a-97b3-ad7cece3e9de Task timed out after 10.01 seconds . What's really weird is that I can see the output being returned correctly in the logs. Also looking for some advice , hope someone can help!
    Hi, I’m using netlify cli and thought it would be nice If I can test with AVA and $ netlify functions:invoke myfunction --payload “graphql query payload”. Do you think its posible to implement?
    I am having an issue in AWS lambda nodejs 12.x. I am trying to get data from another rest api using https module. It seems the code is not executing (only https module part).
    let dataString = '';
    const req = https.get(apIUrl, function(res) {
    res.on('data', chunk => {
    dataString += chunk;
    res.on('end', () => {
    V2K Hacker
    Hi. I'm trying to implement rate limiting by updating app_metadata and I'm going by this is an example: https://www.netlify.com/blog/2018/03/29/jamstack-architecture-on-netlify-how-identity-and-functions-work-together/ However, I'm not getting any answer back from /.netlify/identity/admin/users/... You can see my code at https://github.com/v2khacker/sapper/blob/master/functions/transaction.js The last console.log I get is the HEADERS on line 48.
    V2K Hacker
    I figured out my problem. I forgot to put default after my node-fetch require, so I needed: const fetch = require('node-fetch').default
    Hello all! Are there any examples out there on how to deploy lambda functions along with the lambda layers they use to netlify?
    Well, I suppose that's a "no" :-)
    Matt Gregg
    Anyone know why a function named with a dash in it would return a 403? Works fine using netlify dev locally but once deployed it doesn't work. Removing the dash and having a single word makes it work fine.
    Matt Gregg
    Actually I figured it out: you can't make a function called submission-created and hit it externally. It's reserved for form submissions. So don't go making any custom functions with these names lol https://docs.netlify.com/functions/trigger-on-events/#available-triggers
    Felipe Silveira
    Hello, I'm trying to host a static folder using netlify-lambda but it is not serving, just router is working.
    Does anyone have an idea how to solve this?
    const express = require("express");
    const serverless = require("serverless-http");
    const app = express();
    const router = express.Router();
    router.get("/", (req, res) => {
      res.json({ message: "api working!" })
    app.use("/.netlify/functions/api", router);
    module.exports.handler = serverless(app);
    Muhammad Javed
    Hi, I'm using netlify functions with gatsby, the function is working fine but response.json() throws an error
    function url: https://pantherspainting.com/.netlify/functions/rating-count
    code: https://github.com/theahmadzai/pantherspainting/blob/master/src/pages/services.js#L17
    the function is returning valid JSON but the fetch is behaving like it is not getting valid JSON, it also keeps reloading the page in dev mode.
    function code:
    exports.handler = async () => {
      return {
        statusCode: 200,
        body: JSON.stringify({ ratingCount: 5 }),
    Muhammad Javed
    Fixed!! the issue was ./netlify instead of /.netlify
    such a . can ruin your day
    Muhammad Javed
    Is fetching the rating and ratingCount on build time with gatsby-node using graphql schema customization a good practice?
    Yaser Noorollahi
    I have an error in running search-ui on NGINX, can anyone help me?
    I just deployed search ui on a host with SSL certificate and got this error
    This error occurred when i deployed it to NGINX
    Yaser Noorollahi
    listen 443 ssl;
      #server_name _;
      server_name test.com; 
      ssl_certificate /etc/tech.crt;
      ssl_certificate_key /etc/tech.key; 
      root /var/www/html;
      #root /usr/share/nginx/html/; 
      index index.html; 
      auth_basic "Private Property";
      auth_basic_user_file /etc/nginx/.htpasswd;}
    Richard Cox

    Does any know if Lambda supports Node Streams?

    For example

    router.get("/", (req, res) => {
        req.pipe(new stream.Transform(...)).pipe(res);

    This works perfectly locally, but as soon as it's deployed the response time is almost doubled.

    Credentech Stack
    I have a issue on lambdalayer, I try to place my typeorm entity under /lib/nodejs/ folder. Anybody help would be helpful . Thank you in adavance
    Patrick Ray. Huang
    hello, I am getting an error saying "Could not proxy request /.netlify/functions/search from localhost:3000 to http://localhost:9000", could someone shed a light on what would causing such error? thanks
    Priscilla Pi
    Hello, I was wondering if anyone has added any third-party log management tool like Loggly or LogDNA to their Netlify Serverless Functions?
    Sachin Mittal
    How to autowire dependencies inside a lambda class which extends MicronautRequestHandler?
    Sachin Mittal
    Jarrett Lusso
    is there a good way to write a function that can redirect based on accept-language header. for example I want to put a function at /* to check and conditionally redirect. can a lambda function return out and let Netlify shadow the page that exists at the given path?