package.json 中的 netlify lambda 配置

netlify lambda configuration in package.json

我正在努力关注这篇文章https://www.netlify.com/blog/2018/07/09/building-serverless-crud-apps-with-netlify-functions-faunadb/

它是一个 reactjs 应用程序。 我们 运行 npm i netlify-lambda --save-dev 然后在 package.json

中做了这个配置
{
  "name": "react-lambda",
  ...
  "proxy": {
    "/.netlify/functions": {
      "target": "http://localhost:9000",
      "pathRewrite": {
        "^/\.netlify/functions": ""
      }
    }
  }
}

有人请解释这里发生了什么,我是新手,不懂语法,喜欢 ^/\。 和整体图

pathRewrite是正则表达式。

  • ^:表示字符串的开始。

这会将对 /.netlify/functions 的请求重定向到端口 9000 的本地 运行 功能服务器(由于 target 配置)。