Search code examples
reactjsgatsbypackage.jsonnetlify

netlify lambda configuration in package.json


Im trying to follow this article https://www.netlify.com/blog/2018/07/09/building-serverless-crud-apps-with-netlify-functions-faunadb/

its a reactjs app. we ran npm i netlify-lambda --save-dev then did this configuration in package.json

{
  "name": "react-lambda",
  ...
  "proxy": {
    "/.netlify/functions": {
      "target": "http://localhost:9000",
      "pathRewrite": {
        "^/\\.netlify/functions": ""
      }
    }
  }
}

someone plz explain what is happening here im newbie and dont understand syntax and like ^/\. and overall picture


Solution

  • pathRewrite is a regular expression.

    • ^: indicates the beginning of a string.

    This will redirect the requests made to /.netlify/functions to the locally-running function server at port 9000 (due to target configuration).